@@ -8,6 +8,7 @@ import * as AvaxpLib from '../../../src/lib';
8
8
import { TransactionBuilderFactory } from '../../../src/lib' ;
9
9
import { PermissionlessValidatorTxBuilder } from '../../../src/lib/permissionlessValidatorTxBuilder' ;
10
10
import * as testData from '../../resources/avaxp' ;
11
+ import { ERROR_CHANGE_AMOUNT } from '../../resources/errors' ;
11
12
// import { pvm } from '@bitgo/avalanchejs';
12
13
13
14
describe ( 'AvaxP permissionlessValidatorTxBuilder' , ( ) => {
@@ -298,4 +299,27 @@ describe('AvaxP permissionlessValidatorTxBuilder', () => {
298
299
console . log ( fullSignedTx . toJson ( ) ) ;
299
300
} ) ;
300
301
} ) ;
302
+ it ( 'Should fail to build if utxos change output 0' , async ( ) => {
303
+ const unixNow = BigInt ( Math . round ( new Date ( ) . getTime ( ) / 1000 ) ) ;
304
+ const startTime = unixNow + BigInt ( 60 ) ;
305
+ const endTime = startTime + BigInt ( 60 * 60 * 24 + 600 ) ;
306
+
307
+ const txBuilder = new AvaxpLib . TransactionBuilderFactory ( coins . get ( 'tavaxp' ) )
308
+ . getPermissionlessValidatorTxBuilder ( )
309
+ . threshold ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . threshold )
310
+ . locktime ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . locktime )
311
+ . recoverMode ( false )
312
+ . fromPubKey ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . bitgoAddresses )
313
+ . startTime ( startTime . toString ( ) )
314
+ . endTime ( endTime . toString ( ) )
315
+ . stakeAmount ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . stakeAmountNoOutput )
316
+ . delegationFeeRate ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . delegationFeeRate )
317
+ . nodeID ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . nodeId )
318
+ . blsPublicKey ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . blsPublicKey )
319
+ . blsSignature ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . blsSignature )
320
+ . utxos ( testData . BUILD_AND_SIGN_ADD_PERMISSIONLESS_VALIDATOR_SAMPLE . utxos ) ;
321
+ await txBuilder . build ( ) . catch ( ( error ) => {
322
+ assert ( error . message === ERROR_CHANGE_AMOUNT ) ;
323
+ } ) ;
324
+ } ) ;
301
325
} ) ;
0 commit comments