Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Aug 29, 2024
1 parent 94dcb32 commit c3ff20a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions yarn-project/end-to-end/src/spartan/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,15 @@ describe('token transfer test', () => {

it('can transfer 1 publicly', async () => {
const transferAmount = 1n;
const numTransfers = MINT_AMOUNT / transferAmount;
const initialBalance = await tokenAtWallet0.methods.balance_of_public(completeAddresses[0].address).simulate();
expect(initialBalance).toBeGreaterThanOrEqual(transferAmount);
const sentTxs = [];
for (let i = 1n; i <= MINT_AMOUNT / transferAmount; i++) {
sentTxs.push(
tokenAtWallet0.methods
.transfer_public(completeAddresses[0].address, completeAddresses[1].address, transferAmount, 0)
.send(),
);
for (let i = 1n; i <= numTransfers; i++) {
await tokenAtWallet0.methods
.transfer_public(completeAddresses[0].address, completeAddresses[1].address, transferAmount, 0)
.send()
.wait();
}
await Promise.all(sentTxs.map(tx => tx.wait()));
const finalBalance0 = await tokenAtWallet0.methods.balance_of_public(completeAddresses[0].address).simulate();
expect(finalBalance0).toBe(0n);
const finalBalance1 = await tokenAtWallet0.methods.balance_of_public(completeAddresses[1].address).simulate();
Expand All @@ -140,13 +138,12 @@ describe('token transfer test', () => {

it('can transfer 1 privately', async () => {
const transferAmount = 1n;
const numTransfers = MINT_AMOUNT / transferAmount;
const initialBalance = await tokenAtWallet0.methods.balance_of_private(completeAddresses[0].address).simulate();
expect(initialBalance).toBeGreaterThanOrEqual(transferAmount);
const sentTxs = [];
for (let i = 1n; i <= MINT_AMOUNT / transferAmount; i++) {
sentTxs.push(tokenAtWallet0.methods.transfer(completeAddresses[1].address, transferAmount).send());
for (let i = 1n; i <= numTransfers; i++) {
await tokenAtWallet0.methods.transfer(completeAddresses[1].address, transferAmount).send().wait();
}
await Promise.all(sentTxs.map(tx => tx.wait()));
const finalBalance0 = await tokenAtWallet0.methods.balance_of_private(completeAddresses[0].address).simulate();
expect(finalBalance0).toBe(0n);
const finalBalance1 = await tokenAtWallet0.methods.balance_of_private(completeAddresses[1].address).simulate();
Expand Down

0 comments on commit c3ff20a

Please sign in to comment.