Deep Freeze XLS-77d (#2873) (#29)

Co-authored-by: Chenna Keshava B S <21219765+ckeshava@users.noreply.github.com>
Co-authored-by: Denis Angell <dangell@transia.co>
This commit is contained in:
tequ
2025-10-03 01:51:18 +09:00
committed by GitHub
parent 043620b637
commit 5ec5ad8e1e
7 changed files with 143 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
import { assert } from 'chai'
import { TrustSet, percentToQuality, Wallet } from '../../../src'
import { RippleState } from '../../../src/models/ledger/index'
import { RippleStateFlags } from '../../../src/models/ledger/RippleState'
import serverUrl from '../serverUrl'
import {
setupClient,
@@ -85,4 +87,60 @@ describe('TrustSet', function () {
},
TIMEOUT,
)
it(
'Create a Deep-Frozen trustline',
async () => {
assert(wallet2 != null)
// deep-freeze a trustline with the specified counter-party/currency-code
const tx: TrustSet = {
TransactionType: 'TrustSet',
Account: testContext.wallet.classicAddress,
LimitAmount: {
currency: 'USD',
issuer: wallet2.classicAddress,
value: '10',
},
Flags: {
tfSetFreeze: true,
tfSetDeepFreeze: true,
},
}
const response = await testTransaction(
testContext.client,
tx,
testContext.wallet,
)
assert.equal(response.result.engine_result, 'tesSUCCESS')
// assert that the trustline is frozen
const trustLine = await testContext.client.request({
command: 'account_lines',
account: testContext.wallet.classicAddress,
})
assert.equal(trustLine.result.lines[0].freeze, true)
// verify that the trust-line is deep-frozen
// this operation cannot be done with the account_lines RPC
const account_objects = await testContext.client.request({
command: 'account_objects',
account: testContext.wallet.classicAddress,
})
const rippleState = account_objects.result
.account_objects[0] as RippleState
// Depending on the pseudo-random generation of accounts,
// either of the below leger-object flags must be set
const hasDeepFreeze =
// eslint-disable-next-line no-bitwise -- required to validate flag
(rippleState.Flags & RippleStateFlags.lsfHighDeepFreeze) |
// eslint-disable-next-line no-bitwise -- required to validate flag
(rippleState.Flags & RippleStateFlags.lsfLowDeepFreeze)
assert.isTrue(hasDeepFreeze !== 0)
},
TIMEOUT,
)
})