Skip to content

Commit b13e42d

Browse files
committed
add test
1 parent 9cd74ed commit b13e42d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/unit/portal.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,51 @@ describe('Portal unit tests', () => {
11141114
expect(extParsedTokenAccount.amount).toBe(9198n);
11151115
});
11161116

1117+
it('extension tokens - redeem to portal authority', async () => {
1118+
const [portalAuth] = PublicKey.findProgramAddressSync([Buffer.from('token_authority')], config.PORTAL_PROGRAM_ID);
1119+
1120+
const getRedeemTxns = redeem(
1121+
[],
1122+
undefined,
1123+
true,
1124+
undefined,
1125+
true, // skip release ix
1126+
);
1127+
1128+
await ssw(ctx, getRedeemTxns(), signer);
1129+
1130+
// try to release to portal authority
1131+
const ix = await NTT.createReleaseInboundMintInstruction(ntt.program, await ntt.getConfig(), {
1132+
payer: payer.publicKey,
1133+
nttMessage: payload,
1134+
recipient: portalAuth,
1135+
chain: 'Ethereum',
1136+
revertOnDelay: false,
1137+
});
1138+
1139+
// add additional keys required for portal CPI
1140+
ix.keys.push(
1141+
{
1142+
pubkey: config.EARN_PROGRAM,
1143+
isSigner: false,
1144+
isWritable: false,
1145+
},
1146+
{
1147+
pubkey: config.EARN_GLOBAL_ACCOUNT,
1148+
isSigner: false,
1149+
isWritable: true,
1150+
},
1151+
);
1152+
1153+
const tx = new Transaction().add(ix);
1154+
tx.feePayer = payer.publicKey;
1155+
tx.recentBlockhash = svm.latestBlockhash();
1156+
tx.sign(payer);
1157+
1158+
const result = svm.sendTransaction!(tx) as FailedTransactionMetadata;
1159+
expect(result.meta().logs()[2]).toContain('Error Code: InvalidRecipientAddress');
1160+
});
1161+
11171162
it('tokens with merkle roots', async () => {
11181163
const additionalPayload = Buffer.concat([
11191164
new BN(123456).toArrayLike(Buffer, 'be', 8), // index

0 commit comments

Comments
 (0)