[V117-specific] Resolve broken invariants of manager_txout refunds
[V117-specific]
Intended to close #1590 (closed)
'[bug] manage_thorname failures cause asgard insolvency'
(as partly described in a discussion thread there).
Relevant regression test results (from before the commits which resolve them):
https://gitlab.com/thorchain/thornode/-/jobs/4722040543
ERR cmd/run.go:296 > invariants failed error="asgard invariant is broken: [insolvent: 2000000rune]"
https://gitlab.com/thorchain/thornode/-/jobs/4721807208
ERR cmd/run.go:296 > invariants failed error="asgard invariant is broken: [oversolvent: 2000thor.btc]"
A side-note (not for this MR): \
I noted that TestLoanSwapFails for instance specifies that a 1 BTC.BTC inbound should have 1 BTC.BTC refunded with no fee deduction,
because the unit test doesn't set units for its BTC.BTC pool
and manager_txout currently decides whether to deduct an asset fee based on units rather than non-zero balances.
|
My inclination is to change this check to balances instead, so that an EnableDerivedAssets
TOR (a unitless pool) refund or outbound would deduct the native outbound fee as expected.