Skip to content

Commit

Permalink
feat: extra bouncer diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
dandanlen committed Feb 16, 2024
1 parent 29f2f0a commit b40c433
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bouncer/tests/broker_fee_collection_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,18 @@ async function testBrokerFees(asset: Asset, seed?: string): Promise<void> {
const balanceBeforeWithdrawalBigInt = BigInt(
amountToFineAmount(balanceBeforeWithdrawal, assetDecimals[asset]),
);
const minExpectedBalanceAfterWithdrawal =
balanceBeforeWithdrawalBigInt + earnedBrokerFeesAfter - maxWithdrawalFee[asset];
const detectWithdrawalGasFee =
balanceBeforeWithdrawalBigInt + earnedBrokerFeesAfter - balanceAfterWithdrawalBigInt;
if (['FLIP', 'DOT', 'USDC'].includes(asset.toString())) {
const chainState = JSON.stringify(
await chainflip.query.ethereumChainTracking.currentChainState(),
);
console.log('Ethereum chain tracking state:', chainState);
}
assert(
balanceAfterWithdrawalBigInt >= minExpectedBalanceAfterWithdrawal &&
detectWithdrawalGasFee <= maxWithdrawalFee[asset] &&
balanceAfterWithdrawalBigInt <= balanceBeforeWithdrawalBigInt + earnedBrokerFeesAfter,
`Unexpected ${asset} balance after withdrawal, amount ${balanceAfterWithdrawalBigInt}, expected >=${minExpectedBalanceAfterWithdrawal}, did gas fees change? detected gas fee: ${detectWithdrawalGasFee}`,
`Unexpected ${asset} balance after withdrawal, amount ${balanceAfterWithdrawalBigInt}, did gas fees change? Max expected gas fee is ${maxWithdrawalFee[asset]}, detected gas fee: ${detectWithdrawalGasFee}`,
);
}

Expand Down

0 comments on commit b40c433

Please sign in to comment.