Add ForcedExit test to the integration-simple
@@ -154,6 +154,46 @@ async function testTransfer(syncWallet1: Wallet, syncWallet2: Wallet, token: typ
}
}
+async function testForcedExit(syncWallet1: Wallet, token: types.TokenLike, amount: utils.BigNumber) {
+ const targetEthWallet = ethers.Wallet.createRandom().connect(ethersProvider);
+ const targetWallet = await Wallet.fromEthSigner(
+ targetEthWallet,
+ syncProvider,
+ );
+
+ // Do a transfer to new operation.
+ const transferFullFee = await syncProvider.getTransactionFee("Transfer", targetWallet.address(), token);
+ const transferFee = transferFullFee.totalFee;
+
+ const transferToNewHandle = await syncWallet1.syncTransfer({
+ to: targetWallet.address(),
+ token,
+ amount,
+ fee: transferFee
+ });
+ await transferToNewHandle.awaitReceipt();
+
+ // Then do a ForcedExit operation.
+ const fullFee = await syncProvider.getTransactionFee("Withdraw", targetWallet.address(), token);
+ const fee = fullFee.totalFee;
+
+ let testPassed = true;
+ try {
+ const forcedExitHandle = await syncWallet1.syncForcedExit({
+ target: targetWallet.address(),
+ token,
+ fee
+ });
+ testPassed = false;
+ } catch (err) {
+ console.log('Error (expected) of ForcedExit: ', err.message);
+ }
+
+ if (!testPassed) {
+ throw new Error("ForcedExit was accepted for a fresh account");
+ }
+}
+
async function testWithdraw(contract: Contract, withdrawTo: Wallet, syncWallet: Wallet, token: types.TokenLike, amount: utils.BigNumber) {
const fullFee = await syncProvider.getTransactionFee("Withdraw", withdrawTo.address(), token);
const fee = fullFee.totalFee;
@@ -269,6 +309,8 @@ async function moveFunds(contract: Contract, ethProxy: ETHProxy, depositWallet:
console.log(`Forever approved deposit ok, Token: ${token}`);
await testChangePubkeyOnchain(syncWallet1);
console.log(`Change pubkey onchain ok`);
+ await testForcedExit(syncWallet1, token, transfersAmount);
+ console.log(`ForcedExit OK`);
await testTransfer(syncWallet1, syncWallet2, token, transfersAmount);
console.log(`Transfer to new ok, Token: ${token}`);
await testTransfer(syncWallet1, syncWallet2, token, transfersAmount,);
