-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from ar-io/PE-6579-add-ant-validation
feat(PE-6579): add AoAntState typeguard util
- Loading branch information
Showing
2 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import assert from 'node:assert'; | ||
|
||
import { isAoANTState } from '../../src/utils/ao'; | ||
|
||
const testAoANTState = { | ||
Name: 'TestToken', | ||
Ticker: 'TST', | ||
Denomination: 1, | ||
Owner: ''.padEnd(43, '1'), | ||
Controllers: [''.padEnd(43, '2')], | ||
Records: { | ||
record1: { | ||
transactionId: ''.padEnd(43, '1'), | ||
ttlSeconds: 3600, | ||
}, | ||
}, | ||
Balances: { | ||
[''.padEnd(43, '1')]: 1, | ||
}, | ||
Logo: ''.padEnd(43, '1'), | ||
TotalSupply: 0, | ||
Initialized: true, | ||
}; | ||
describe('ANT', () => { | ||
it('should validate accurate ANT state', () => { | ||
const res = isAoANTState(testAoANTState); | ||
assert.strictEqual(res, true); | ||
}); | ||
|
||
it('should invalidate inaccurate ANT state', () => { | ||
const res = isAoANTState({ ...testAoANTState, Name: 1 }); | ||
assert.strictEqual(res, false); | ||
}); | ||
}); |