mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Parse transaction flags into map of names:booleans (#2734)
* overview logic of parsetransactionflags * parse transaction flags works * basic tests * eslint and docs * linting * lint * fix typing * test fix * revert import delete * lint * integration fix * lint * imports * added numeric test * add history log * history update
This commit is contained in:
@@ -17,6 +17,7 @@ import { isFlagEnabled } from '../../src/models/utils'
|
||||
import {
|
||||
setTransactionFlagsToNumber,
|
||||
parseAccountRootFlags,
|
||||
parseTransactionFlags,
|
||||
} from '../../src/models/utils/flags'
|
||||
|
||||
/**
|
||||
@@ -207,5 +208,60 @@ describe('Models Utils', function () {
|
||||
assert.isUndefined(parsed.lsfDisallowIncomingTrustline)
|
||||
assert.isUndefined(parsed.lsfAllowTrustLineClawback)
|
||||
})
|
||||
|
||||
it('parseTransactionFlags all enabled', function () {
|
||||
const tx: PaymentChannelClaim = {
|
||||
Account: 'r...',
|
||||
TransactionType: 'PaymentChannelClaim',
|
||||
Channel:
|
||||
'C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198',
|
||||
Flags: {
|
||||
tfRenew: true,
|
||||
tfClose: false,
|
||||
},
|
||||
}
|
||||
|
||||
const expected = {
|
||||
tfRenew: true,
|
||||
}
|
||||
|
||||
const flagsMap = parseTransactionFlags(tx)
|
||||
assert.notStrictEqual(flagsMap, expected)
|
||||
})
|
||||
|
||||
it('parseTransactionFlags all false', function () {
|
||||
const tx: PaymentChannelClaim = {
|
||||
Account: 'r...',
|
||||
TransactionType: 'PaymentChannelClaim',
|
||||
Channel:
|
||||
'C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198',
|
||||
Flags: {
|
||||
tfRenew: false,
|
||||
tfClose: false,
|
||||
},
|
||||
}
|
||||
|
||||
const expected = {}
|
||||
|
||||
const flagsMap = parseTransactionFlags(tx)
|
||||
assert.notStrictEqual(flagsMap, expected)
|
||||
})
|
||||
|
||||
it('parseTransactionFlags flag is already numeric', function () {
|
||||
const tx: PaymentChannelClaim = {
|
||||
Account: 'r...',
|
||||
TransactionType: 'PaymentChannelClaim',
|
||||
Channel:
|
||||
'C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198',
|
||||
Flags: 65536,
|
||||
}
|
||||
|
||||
const expected = {
|
||||
tfRenew: true,
|
||||
}
|
||||
|
||||
const flagsMap = parseTransactionFlags(tx)
|
||||
assert.notStrictEqual(flagsMap, expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user