From fef3e6dcf0e32cb51d304a62424da192aeec506d Mon Sep 17 00:00:00 2001 From: Support Bot Date: Tue, 21 Jul 2026 15:39:53 +0000 Subject: [PATCH] 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 Session-Id: b9aaf785-eb22-46b4-853a-ee44f3d06a1a Task-Id: 0bb9551a-800d-4e1e-b09f-fe82f03b7754 --- modules/sdk-coin-eos/test/unit/eos.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/sdk-coin-eos/test/unit/eos.ts b/modules/sdk-coin-eos/test/unit/eos.ts index a72f611d8f..0ac0d37812 100644 --- a/modules/sdk-coin-eos/test/unit/eos.ts +++ b/modules/sdk-coin-eos/test/unit/eos.ts @@ -35,6 +35,10 @@ describe('EOS:', function () { addressDetails.address.should.equal('ks13k3hdui24'); addressDetails.memoId.should.equal('1'); + addressDetails = basecoin.getAddressDetails('ks13k3hdui24?memoId=0'); + addressDetails.address.should.equal('ks13k3hdui24'); + addressDetails.memoId.should.equal('0'); + (() => { basecoin.getAddressDetails('ks13k3hdui24?memoId=1&memoId=2'); }).should.throw(); @@ -52,6 +56,7 @@ describe('EOS:', function () { basecoin.isValidAddress('ks13kdh245ls').should.equal(true); basecoin.isValidAddress('ks13k3hdui24?memoId=1').should.equal(true); basecoin.isValidAddress('ks13k3hdui24?memoId=x').should.equal(true); + basecoin.isValidAddress('ks13k3hdui24?memoId=0').should.equal(true); }); it('verifyAddress should work', async function () { @@ -63,6 +68,10 @@ describe('EOS:', function () { address: 'ks13kdh245ls?memoId=1', rootAddress: 'ks13kdh245ls', }); + await basecoin.verifyAddress({ + address: 'ks13kdh245ls?memoId=0', + rootAddress: 'ks13kdh245ls', + }); assert.rejects(basecoin.verifyAddress({ address: 'i1skda3kso43=x', rootAddress: 'i1skda3kso43' })); assert.rejects(basecoin.verifyAddress({ address: 'i1skda3kso43?memoId=243432', rootAddress: 'ks13kdh245ls' })); @@ -83,6 +92,7 @@ describe('EOS:', function () { }); it('isValidMemoId should work', function () { + basecoin.isValidMemoId('0').should.equal(true); basecoin.isValidMemoId('1').should.equal(true); basecoin.isValidMemoId('123abc').should.equal(true); basecoin.isValidMemoId(EosInputs.string257CharsLong).should.equal(false); @@ -511,5 +521,20 @@ describe('EOS:', function () { const validTransaction = await basecoin.verifyTransaction({ txParams, txPrebuild, wallet, verification }); validTransaction.should.equal(true); }); + + it('should verify a transaction with memoId=0', async function () { + const txPrebuild = newTxPrebuild(); + // Transaction with memo='0' (memoId zero is the first receive address) + txPrebuild.txHex = + '2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a9107468401e0c7a61a3a7b5e7c4470000000100408c7a02ea3055000000000085269d00030233330100a6823403ea3055000000572d3ccdcd0120ceb8437333427c00000000a8ed32322220ceb8437333427c20825019ab3ca98be80300000000000004454f5300000000013000000000000000000000000000000000000000000000000000000000000000000000'; + txPrebuild.transaction.packed_trx = + '1e0c7a61a3a7b5e7c4470000000100408c7a02ea3055000000000085269d00030233330100a6823403ea3055000000572d3ccdcd0120ceb8437333427c00000000a8ed32322220ceb8437333427c20825019ab3ca98be80300000000000004454f5300000000013000'; + const txParams = newTxParams(); + txParams.recipients[0].address = 'lionteste212?memoId=0'; + txParams.txPrebuild = txPrebuild; + + const validTransaction = await basecoin.verifyTransaction({ txParams, txPrebuild, wallet, verification }); + validTransaction.should.equal(true); + }); }); });