From bf63fd0173522bf26a83806af4e5f000eecfaec1 Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Fri, 19 May 2023 00:24:49 +0000 Subject: [PATCH] add autofill tests --- packages/xrpl/test/client/autofill.test.ts | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/xrpl/test/client/autofill.test.ts b/packages/xrpl/test/client/autofill.test.ts index cfb93f2c..32c8b53f 100644 --- a/packages/xrpl/test/client/autofill.test.ts +++ b/packages/xrpl/test/client/autofill.test.ts @@ -15,6 +15,7 @@ import { } from '../setupClient' import { assertRejects } from '../testUtils' +const NetworkID = 1025 const Fee = '10' const Sequence = 1432 const LastLedgerSequence = 2908734 @@ -32,17 +33,54 @@ describe('client.autofill', function () { TransactionType: 'DepositPreauth', Account: 'rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf', Authorize: 'rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo', + NetworkID, Fee, Sequence, LastLedgerSequence, } const txResult = await testContext.client.autofill(tx) + assert.strictEqual(txResult.NetworkID, NetworkID) assert.strictEqual(txResult.Fee, Fee) assert.strictEqual(txResult.Sequence, Sequence) assert.strictEqual(txResult.LastLedgerSequence, LastLedgerSequence) }) + it('ignores network ID if < 1024 and its missing', async function () { + const tx: Payment = { + TransactionType: 'Payment', + Account: 'XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi', + Amount: '1234', + Destination: 'X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ', + Fee, + Sequence, + LastLedgerSequence, + } + testContext.mockRippled!.addResponse('ledger', rippled.ledger.normal) + + const txResult = await testContext.client.autofill(tx) + + assert.strictEqual(txResult.NetworkID, undefined) + }) + + it('override network ID if > 1024 and its missing', async function () { + testContext.client.networkID = 1025 + const tx: Payment = { + TransactionType: 'Payment', + Account: 'XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi', + Amount: '1234', + Destination: 'X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ', + Fee, + Sequence, + LastLedgerSequence, + } + testContext.mockRippled!.addResponse('ledger', rippled.ledger.normal) + + const txResult = await testContext.client.autofill(tx) + + assert.strictEqual(txResult.NetworkID, 1025) + }) + it('converts Account & Destination X-address to their classic address', async function () { const tx: Payment = { TransactionType: 'Payment',