Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #723 from ConnextProject/refactor-test-runner
Browse files Browse the repository at this point in the history
fix pre balances
  • Loading branch information
pedrouid committed Jan 13, 2020
2 parents d32fb82 + 7330e35 commit 3e9c3c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions modules/test-runner/src/channelProvider/channelProvider.test.ts
@@ -1,6 +1,6 @@
import { xkeyKthAddress } from "@connext/cf-core";
import { IChannelProvider, IConnextClient } from "@connext/types";
import { AddressZero, Zero } from "ethers/constants";
import { AddressZero } from "ethers/constants";
import { bigNumberify } from "ethers/utils";

import {
Expand Down Expand Up @@ -67,20 +67,26 @@ describe("ChannelProvider", () => {

////////////////////////////////////////
// TRANSFER FLOW
const transferAmount = bigNumberify(ONE);
const assetId = AddressZero;
const transfer = { amount: bigNumberify(ONE), assetId: AddressZero };
const clientB = await createClient();
await clientB.requestCollateral(AddressZero);

await asyncTransferAsset(clientA1, clientB, transferAmount, assetId, nodeFreeBalanceAddress, {
freeBalanceClientA: freeBalanceClientEth,
freeBalanceNodeA: freeBalanceNodeEth,
});
await asyncTransferAsset(
clientA1,
clientB,
transfer.amount,
transfer.assetId,
nodeFreeBalanceAddress,
{
freeBalanceClientA: freeBalanceClientEth,
freeBalanceNodeA: freeBalanceNodeEth,
},
);

////////////////////////////////////////
// WITHDRAW FLOW
const withdrawAmount = bigNumberify(ONE);
await withdrawFromChannel(clientA1, withdrawAmount.toString(), AddressZero);
const withdraw = { amount: bigNumberify(ONE), assetId: AddressZero };
await withdrawFromChannel(clientA1, withdraw.amount.toString(), withdraw.assetId);
});

// tslint:disable-next-line:max-line-length
Expand Down
4 changes: 2 additions & 2 deletions modules/test-runner/src/util/helpers/swapAsset.ts
Expand Up @@ -19,8 +19,8 @@ export async function swapAsset(
freeBalanceClientEth: ethToToken ? input.amount : Zero,
freeBalanceNodeEth: ethToToken ? Zero : output.amount,
// tslint:disable-next-line:object-literal-sort-keys
freeBalanceClientToken: ethToToken ? output.amount : Zero,
freeBalanceNodeToken: ethToToken ? Zero : input.amount,
freeBalanceClientToken: ethToToken ? Zero : input.amount,
freeBalanceNodeToken: ethToToken ? output.amount : Zero,
...preExistingBalances,
};

Expand Down

0 comments on commit 3e9c3c5

Please sign in to comment.