feat: Add parseAccountRootFlags (#1699)

* Add parseAccountRootFlags and interface

* Add tests for parseAccountRootFlags
This commit is contained in:
Jackson Mills
2021-10-07 16:23:42 -07:00
committed by GitHub
parent 0674d21134
commit 7e70142044
3 changed files with 84 additions and 1 deletions

View File

@@ -12,8 +12,11 @@ import {
TrustSet,
TrustSetFlags,
} from 'xrpl-local'
import { AccountRootFlags } from 'xrpl-local/models/ledger'
import { isFlagEnabled } from 'xrpl-local/models/utils'
import setTransactionFlagsToNumber from 'xrpl-local/models/utils/flags'
import setTransactionFlagsToNumber, {
parseAccountRootFlags,
} from 'xrpl-local/models/utils/flags'
/**
* Utils Testing.
@@ -146,5 +149,46 @@ describe('Models Utils', function () {
setTransactionFlagsToNumber(tx)
assert.strictEqual(tx.Flags, 0)
})
it('parseAccountRootFlags all enabled', function () {
const accountRootFlags =
AccountRootFlags.lsfDefaultRipple |
AccountRootFlags.lsfDepositAuth |
AccountRootFlags.lsfDisableMaster |
AccountRootFlags.lsfDisallowXRP |
AccountRootFlags.lsfGlobalFreeze |
AccountRootFlags.lsfNoFreeze |
AccountRootFlags.lsfPasswordSpent |
AccountRootFlags.lsfRequireAuth |
AccountRootFlags.lsfRequireDestTag
const parsed = parseAccountRootFlags(accountRootFlags)
assert.isTrue(
parsed.lsfDefaultRipple &&
parsed.lsfDepositAuth &&
parsed.lsfDisableMaster &&
parsed.lsfDisallowXRP &&
parsed.lsfGlobalFreeze &&
parsed.lsfNoFreeze &&
parsed.lsfPasswordSpent &&
parsed.lsfRequireAuth &&
parsed.lsfRequireDestTag,
)
})
it('parseAccountFlags all false', function () {
const parsed = parseAccountRootFlags(0)
assert.isUndefined(parsed.lsfDefaultRipple)
assert.isUndefined(parsed.lsfDepositAuth)
assert.isUndefined(parsed.lsfDisableMaster)
assert.isUndefined(parsed.lsfDisallowXRP)
assert.isUndefined(parsed.lsfGlobalFreeze)
assert.isUndefined(parsed.lsfNoFreeze)
assert.isUndefined(parsed.lsfPasswordSpent)
assert.isUndefined(parsed.lsfRequireAuth)
assert.isUndefined(parsed.lsfRequireDestTag)
})
})
})