Commit 66c2e25
committed
tests: stop force-loading plugin into AppDomain - lets PluginLoader register MVC parts
The actual root cause of master CI #22's OTP-404 failure (and the
v1.1.0-cycle GetService<TPluginService> null result I worked around
with HTTP-only testing): the fixture ctor was force-loading the
plugin assembly into the AppDomain via typeof(SamRockProtocolPlugin).
PluginManager.AddPlugins at submodules/btcpayserver/BTCPayServer/
Plugins/PluginManager.cs:155 scans AppDomain.CurrentDomain.GetAssemblies()
FIRST via PreloadPluginsFromAssemblies and registers any plugin it
finds there with Loader=null (line 135). Later when the DEBUG_PLUGINS
/ plugins-folder path tries to add the same plugin via
PluginLoader.CreateFromAssemblyFile, the dedup check at line 204
(if preloadedPlugins.Contains(identifier) continue) skips it.
The AppDomain-scanned plugin then takes the Loader=null branch at
line 246-256: AddAssemblyLoadContexts is skipped, GetPluginInstanceFromAssembly
still runs (so the IBTCPayServerPlugin shows in DI), but
mvcBuilder.AddPluginLoader(loader) at line 256 is SKIPPED because
Loader is null. MVC ApplicationParts never includes the plugin's
assembly, controllers never register, all routes 404.
Fix: let the file-based DEBUG_PLUGINS / plugins-folder path resolve
the plugin first via PluginLoader (Loader non-null), which triggers
mvcBuilder.AddPluginLoader and registers the controller assembly
with MVC. Remove the typeof() force-load that was sabotaging this.
Also reverts the LoadPluginsInDefaultAssemblyContext attempt - that
property exists on later BTCPay versions but not on the v2.1.6-20
submodule SamRockProtocol pins, so it doesn't compile here.
The retry-with-backoff in the previous commit on this branch stays
as cheap defense for any residual timing window, but the real fix is
removing the force-load.1 parent 39df92f commit 66c2e25
1 file changed
Lines changed: 9 additions & 13 deletions
File tree
- SamRockProtocol.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 45 | | |
50 | 46 | | |
51 | 47 | | |
| |||
0 commit comments