Skip to content

Commit

Permalink
Improve deposit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eth-r committed Aug 3, 2023
1 parent 373144a commit 8ed32b7
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions cross-chain/solana/tests/02__wormholeGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe("wormhole-gateway", () => {
await tbtc.checkState(tbtcProgram, authority, 2, 2, 2000);
});

it('won\'t deposit wrapped tokens over the minting limit', async () => {
it('- won\'t deposit wrapped tokens over the minting limit', async () => {
const minterInfo = tbtc.getMinterPDA(tbtcProgram, custodian)[0];
const payer = await generatePayer(connection, authority.payer);
const wrappedTbtcToken = await bridgeToSolana(BigInt("100000000000"), connection, payer, ethereumTokenBridge);
Expand All @@ -245,7 +245,7 @@ describe("wormhole-gateway", () => {
}
});

it('won\'t deposit wrapped tokens with mismatched token types', async () => {
it('- won\'t deposit wrapped tokens with mismatched token types', async () => {
const minterInfo = tbtc.getMinterPDA(tbtcProgram, custodian)[0];
const payer = await generatePayer(connection, authority.payer);
const wrappedTbtcToken = await bridgeToSolana(BigInt("100000000000"), connection, payer, ethereumTokenBridge);
Expand Down Expand Up @@ -287,7 +287,7 @@ describe("wormhole-gateway", () => {
}
});

it('won\'t deposit wrapped tokens to wrong address', async () => {
it('- won\'t deposit wrapped tokens to wrong owner', async () => {
const minterInfo = tbtc.getMinterPDA(tbtcProgram, custodian)[0];
const payer = await generatePayer(connection, authority.payer);
const payer2 = await generatePayer(connection, authority.payer);
Expand All @@ -314,4 +314,32 @@ describe("wormhole-gateway", () => {
expect(err.program.equals(program.programId)).is.true;
}
});

it('- won\'t deposit wrapped tokens from wrong owner', async () => {
const minterInfo = tbtc.getMinterPDA(tbtcProgram, custodian)[0];
const payer = await generatePayer(connection, authority.payer);
const payer2 = await generatePayer(connection, authority.payer);
const wrappedTbtcToken = await bridgeToSolana(BigInt("100000000000"), connection, payer, ethereumTokenBridge);
const recipientToken = await getOrCreateTokenAccount(connection, payer, tbtcMint, payer.publicKey);
const wrappedTbtcToken2 = await bridgeToSolana(BigInt("100"), connection, payer2, ethereumTokenBridge);
const recipient2Token = await getOrCreateTokenAccount(connection, payer, tbtcMint, payer2.publicKey);

try {
await depositWormholeTbtc(
program,
tbtcProgram,
50000,
wrappedTbtcToken2.address,
recipientToken.address,
payer,
minterInfo
);
chai.assert(false, "should've failed but didn't");
} catch (_err) {
expect(_err).to.be.instanceOf(AnchorError);
const err: AnchorError = _err;
expect(err.error.errorCode.code).to.equal('ConstraintTokenOwner');
expect(err.program.equals(program.programId)).is.true;
}
});
});

0 comments on commit 8ed32b7

Please sign in to comment.