|
| 1 | +import { BaseKey, BuildTransactionError } from '@bitgo/sdk-core'; |
| 2 | +import assert from 'assert'; |
1 | 3 | import should from 'should';
|
2 |
| -import { getBuilderFactory } from '../getBuilderFactory'; |
3 |
| -import { BaseKey } from '@bitgo/sdk-core'; |
4 |
| -import * as testData from '../../resources/icp'; |
5 | 4 | import sinon from 'sinon';
|
6 | 5 | import { DEFAULT_MEMO, MAX_INGRESS_TTL } from '../../../src/lib/iface';
|
| 6 | +import * as testData from '../../resources/icp'; |
| 7 | +import { getBuilderFactory } from '../getBuilderFactory'; |
7 | 8 |
|
8 | 9 | describe('ICP Transaction Builder', async () => {
|
9 | 10 | const factory = getBuilderFactory('ticp');
|
@@ -66,6 +67,17 @@ describe('ICP Transaction Builder', async () => {
|
66 | 67 | await txBuilder.build().should.rejectedWith('sender is required before building');
|
67 | 68 | });
|
68 | 69 |
|
| 70 | + it('should fail to build a txn with incorrect memo', async () => { |
| 71 | + const txBuilder = factory.getTransferBuilder(); |
| 72 | + txBuilder.sender(testData.Accounts.account1.address, testData.Accounts.account1.publicKey); |
| 73 | + txBuilder.receiverId(testData.Accounts.account2.address); |
| 74 | + txBuilder.amount('10'); |
| 75 | + const incorrectMemos = ['abcd', undefined]; |
| 76 | + for (const memo of incorrectMemos) { |
| 77 | + assert.throws(() => txBuilder.memo(Number(memo)), BuildTransactionError, `Invalid memo: ${Number(memo)}`); |
| 78 | + } |
| 79 | + }); |
| 80 | + |
69 | 81 | it('should fail to build a txn without amount', async () => {
|
70 | 82 | const txBuilder = factory.getTransferBuilder();
|
71 | 83 | txBuilder.sender(testData.Accounts.account1.address, testData.Accounts.account1.publicKey);
|
|
0 commit comments