Skip to content

Commit fef3e6d

Browse files
Support Botclaude
authored andcommitted
test(sdk-coin-eos): add coverage for memoId=0 address handling
Add test cases for EOS address handling when memoId equals '0' (the first receive address index). The string '0' is truthy in JavaScript but differs from other memo IDs in being numerically zero, which can trigger subtle falsy-check bugs. Added tests for: - getAddressDetails with ?memoId=0 - isValidAddress with ?memoId=0 - isValidMemoId with value '0' - verifyAddress with ?memoId=0 - verifyTransaction with a tx containing memo='0' and recipient address ?memoId=0 All tests confirm the SDK handles memoId=0 correctly. These tests provide regression coverage against future changes that might inadvertently break the falsy-safe '0' handling. Ticket: COINS-1232 Co-Authored-By: Claude <noreply@anthropic.com> Session-Id: b9aaf785-eb22-46b4-853a-ee44f3d06a1a Task-Id: 0bb9551a-800d-4e1e-b09f-fe82f03b7754
1 parent e759bf0 commit fef3e6d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

  • modules/sdk-coin-eos/test/unit

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ describe('EOS:', function () {
3535
addressDetails.address.should.equal('ks13k3hdui24');
3636
addressDetails.memoId.should.equal('1');
3737

38+
addressDetails = basecoin.getAddressDetails('ks13k3hdui24?memoId=0');
39+
addressDetails.address.should.equal('ks13k3hdui24');
40+
addressDetails.memoId.should.equal('0');
41+
3842
(() => {
3943
basecoin.getAddressDetails('ks13k3hdui24?memoId=1&memoId=2');
4044
}).should.throw();
@@ -52,6 +56,7 @@ describe('EOS:', function () {
5256
basecoin.isValidAddress('ks13kdh245ls').should.equal(true);
5357
basecoin.isValidAddress('ks13k3hdui24?memoId=1').should.equal(true);
5458
basecoin.isValidAddress('ks13k3hdui24?memoId=x').should.equal(true);
59+
basecoin.isValidAddress('ks13k3hdui24?memoId=0').should.equal(true);
5560
});
5661

5762
it('verifyAddress should work', async function () {
@@ -63,6 +68,10 @@ describe('EOS:', function () {
6368
address: 'ks13kdh245ls?memoId=1',
6469
rootAddress: 'ks13kdh245ls',
6570
});
71+
await basecoin.verifyAddress({
72+
address: 'ks13kdh245ls?memoId=0',
73+
rootAddress: 'ks13kdh245ls',
74+
});
6675

6776
assert.rejects(basecoin.verifyAddress({ address: 'i1skda3kso43=x', rootAddress: 'i1skda3kso43' }));
6877
assert.rejects(basecoin.verifyAddress({ address: 'i1skda3kso43?memoId=243432', rootAddress: 'ks13kdh245ls' }));
@@ -83,6 +92,7 @@ describe('EOS:', function () {
8392
});
8493

8594
it('isValidMemoId should work', function () {
95+
basecoin.isValidMemoId('0').should.equal(true);
8696
basecoin.isValidMemoId('1').should.equal(true);
8797
basecoin.isValidMemoId('123abc').should.equal(true);
8898
basecoin.isValidMemoId(EosInputs.string257CharsLong).should.equal(false);
@@ -511,5 +521,20 @@ describe('EOS:', function () {
511521
const validTransaction = await basecoin.verifyTransaction({ txParams, txPrebuild, wallet, verification });
512522
validTransaction.should.equal(true);
513523
});
524+
525+
it('should verify a transaction with memoId=0', async function () {
526+
const txPrebuild = newTxPrebuild();
527+
// Transaction with memo='0' (memoId zero is the first receive address)
528+
txPrebuild.txHex =
529+
'2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a9107468401e0c7a61a3a7b5e7c4470000000100408c7a02ea3055000000000085269d00030233330100a6823403ea3055000000572d3ccdcd0120ceb8437333427c00000000a8ed32322220ceb8437333427c20825019ab3ca98be80300000000000004454f5300000000013000000000000000000000000000000000000000000000000000000000000000000000';
530+
txPrebuild.transaction.packed_trx =
531+
'1e0c7a61a3a7b5e7c4470000000100408c7a02ea3055000000000085269d00030233330100a6823403ea3055000000572d3ccdcd0120ceb8437333427c00000000a8ed32322220ceb8437333427c20825019ab3ca98be80300000000000004454f5300000000013000';
532+
const txParams = newTxParams();
533+
txParams.recipients[0].address = 'lionteste212?memoId=0';
534+
txParams.txPrebuild = txPrebuild;
535+
536+
const validTransaction = await basecoin.verifyTransaction({ txParams, txPrebuild, wallet, verification });
537+
validTransaction.should.equal(true);
538+
});
514539
});
515540
});

0 commit comments

Comments
 (0)