Skip to content

Commit 39df92f

Browse files
committed
tests: load plugin into default AssemblyLoadContext for MVC controller discovery
Real fix for master CI #22 failure (and likely the original race on PR #12 we worked around with HTTP-only testing). Root cause: BTCPay defaults plugin loading to an isolated AssemblyLoadContext so production plugins can be swapped without restarting the server. In the test process, the isolated context makes the plugin's assembly invisible to MVC ApplicationParts discovery - so the plugin's IBTCPayServerPlugin instance shows up in the DI list but POSTs to its controller routes 404. The retry-with-backoff in the previous commit didn't help because the route never registers, not because it lags. Removing the retry loop now that the real fix is in. Mirror of rockstardev/btcPayServerPlugins.RockstarDev's SharedPluginTestFixture which sets LoadPluginsInDefaultAssemblyContext = false before ServerTester.StartAsync().
1 parent 2250d13 commit 39df92f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

SamRockProtocol.Tests/SharedPluginTestFixture.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ public void Initialize(UnitTestBase testInstance)
3737

3838
var testDir = Path.Combine(Directory.GetCurrentDirectory(), _testDirName);
3939
ServerTester = testInstance.CreateServerTester(testDir, _useNewDb);
40+
// BTCPay defaults plugins to isolated AssemblyLoadContext so production
41+
// plugins can be unloaded/swapped without restarting. In tests the
42+
// isolated context makes the plugin's assembly invisible to the test
43+
// process's MVC ApplicationParts discovery, so the controllers never
44+
// route (the plugin shows in DI but POSTs to its endpoints 404).
45+
// Load into the default context so MVC can discover the controllers.
46+
// Mirrors rockstardev/btcPayServerPlugins.RockstarDev's test fixture
47+
// and closes the master CI #22 OTP-404 failure deterministically.
48+
ServerTester.PayTester.LoadPluginsInDefaultAssemblyContext = false;
4049
ServerTester.StartAsync().GetAwaiter().GetResult();
4150
}
4251
}

0 commit comments

Comments
 (0)