refactor: Define PaymentTransaction model (#1542)

- Defines a TypeScript type for PaymentTransaction
- Provides an optional function to users for verifying a PaymentTransaction instance at runtime: verifyPaymentTransaction()
- Adds tests for verifyPaymentTransaction()
- Adds isFlagEnabled() util to be used for models
This commit is contained in:
Omar Khan
2021-08-18 17:24:34 -04:00
committed by Mayukha Vadari
parent c1edab547a
commit bec487cf71
8 changed files with 296 additions and 31 deletions

29
test/models/utils.ts Normal file
View File

@@ -0,0 +1,29 @@
import { isFlagEnabled } from '../../src/models/utils'
import { assert } from 'chai'
/**
* Utils Testing
*
* Provides tests for utils used in models
*/
describe('Models Utils', () => {
describe('isFlagEnabled', () => {
let flags
const flag1 = 0x00010000
const flag2 = 0x00020000
beforeEach(() => {
flags = 0x00000000
})
it('verifies a flag is enabled', () => {
flags += flag1 + flag2
assert.isTrue(isFlagEnabled(flags, flag1))
})
it('verifies a flag is not enabled', () => {
flags += flag2
assert.isFalse(isFlagEnabled(flags, flag1))
})
})
})