Skip to content

Commit 8ef38d8

Browse files
committed
test(sdk-coin-hbar): add sendTokenEnablements test with valid txHex
Ticket: WP-5782
1 parent c7481dd commit 8ef38d8

File tree

1 file changed

+41
-0
lines changed
  • modules/sdk-coin-hbar/test/unit

1 file changed

+41
-0
lines changed

modules/sdk-coin-hbar/test/unit/hbar.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,47 @@ describe('Hedera Hashgraph:', function () {
682682
assert.ok(true, 'Valid token enablement transaction should not throw any errors');
683683
});
684684

685+
it('should successfully complete sendTokenEnablements with valid transaction response from wallet platform', async function () {
686+
const validTxHex = TestData.UNSIGNED_TOKEN_ASSOCIATE;
687+
688+
const wallet = {
689+
id: () => '5b34252f1bf34993006eae96',
690+
coin: () => 'thbar',
691+
prebuildTransaction: async () => ({
692+
txHex: validTxHex, // Valid token associate transaction
693+
txid: '586c5b59b10b134d04c16ac1b273fe3c5529f34aef75db4456cd469c5cdac7e2',
694+
recipients: [{ address: '0.0.81320', amount: '0' }],
695+
coin: 'thbar',
696+
feeInfo: { size: 1000, fee: 1160407, feeRate: 1160407 },
697+
}),
698+
sendTokenEnablements: async (params: any) => {
699+
const txPrebuild = await wallet.prebuildTransaction();
700+
await basecoin.verifyTransaction({
701+
txParams: {
702+
type: 'enabletoken',
703+
recipients: [{ address: '0.0.81320', amount: '0', tokenName: 'thbar:usdc' }],
704+
},
705+
txPrebuild,
706+
verification: { verifyTokenEnablement: true },
707+
});
708+
709+
return {
710+
success: [{ txid: txPrebuild.txid, status: 'success' }],
711+
failure: [],
712+
};
713+
},
714+
};
715+
716+
await wallet.sendTokenEnablements({
717+
recipients: [{ address: '0.0.81320', tokenName: 'thbar:usdc' }],
718+
});
719+
720+
assert.ok(
721+
true,
722+
'Valid token enablement transaction should complete successfully through sendTokenEnablements flow'
723+
);
724+
});
725+
685726
it('should detect spoofed transaction hex through sendTokenEnablements flow', async function () {
686727
// Use a valid transfer transaction hex instead of a token associate transaction
687728
// This will parse correctly but fail validation because it's not a token associate transaction

0 commit comments

Comments
 (0)