@@ -14,6 +14,9 @@ describe('VET Validator Registration Transaction', function () {
1414 const factory = new TransactionBuilderFactory ( coins . get ( 'tvet' ) ) ;
1515 const stakingPeriod = 60480 ;
1616 const validatorAddress = '0x9a7aFCACc88c106f3bbD6B213CD0821D9224d945' ;
17+ const amountToStake = '25000000000000000000000000' ; // 25000000 VET
18+ const amountLessThanMinStake = '24000000000000000000000000' ; // 24000000 VET
19+ const amountGreaterThanMaxStake = '650000000000000000000000000' ; // 650000000 VET
1720
1821 // Helper function to create a basic transaction builder with common properties
1922 const createBasicTxBuilder = ( ) => {
@@ -32,6 +35,7 @@ describe('VET Validator Registration Transaction', function () {
3235 const txBuilder = factory . getValidatorRegistrationBuilder ( ) ;
3336 txBuilder . stakingContractAddress ( VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET ) ;
3437 txBuilder . stakingPeriod ( stakingPeriod ) ;
38+ txBuilder . amountToStake ( amountToStake ) ;
3539 txBuilder . sender ( '0x9378c12BD7502A11F770a5C1F223c959B2805dA9' ) ;
3640 txBuilder . chainTag ( 0x27 ) ; // Testnet chain tag
3741 txBuilder . blockRef ( '0x0000000000000000' ) ;
@@ -52,13 +56,16 @@ describe('VET Validator Registration Transaction', function () {
5256 ) ;
5357 validatorRegistrationTransaction . stakingPeriod . should . equal ( stakingPeriod ) ;
5458 validatorRegistrationTransaction . validator . should . equal ( validatorAddress ) ;
59+ validatorRegistrationTransaction . amountToStake . should . equal ( amountToStake ) ;
5560
5661 // Verify clauses
5762 validatorRegistrationTransaction . clauses . length . should . equal ( 1 ) ;
5863 should . exist ( validatorRegistrationTransaction . clauses [ 0 ] . to ) ;
64+ should . exist ( validatorRegistrationTransaction . clauses [ 0 ] . value ) ;
5965 validatorRegistrationTransaction . clauses [ 0 ] . to ?. should . equal (
6066 VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET
6167 ) ;
68+ validatorRegistrationTransaction . clauses [ 0 ] . value ?. should . equal ( amountToStake ) ;
6269
6370 // Verify transaction data is correctly encoded using ethereumABI
6471 should . exist ( validatorRegistrationTransaction . clauses [ 0 ] . data ) ;
@@ -88,6 +95,7 @@ describe('VET Validator Registration Transaction', function () {
8895 const txBuilder = createBasicTxBuilder ( ) ;
8996 txBuilder . stakingPeriod ( stakingPeriod ) ;
9097 txBuilder . validator ( validatorAddress ) ;
98+ txBuilder . amountToStake ( amountToStake ) ;
9199
92100 await txBuilder . build ( ) . should . be . rejectedWith ( 'Staking contract address is required' ) ;
93101 } ) ;
@@ -96,6 +104,7 @@ describe('VET Validator Registration Transaction', function () {
96104 const txBuilder = createBasicTxBuilder ( ) ;
97105 txBuilder . stakingContractAddress ( VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET ) ;
98106 txBuilder . validator ( validatorAddress ) ;
107+ txBuilder . amountToStake ( amountToStake ) ;
99108
100109 await txBuilder . build ( ) . should . be . rejectedWith ( 'Staking period is required' ) ;
101110 } ) ;
@@ -104,10 +113,40 @@ describe('VET Validator Registration Transaction', function () {
104113 const txBuilder = createBasicTxBuilder ( ) ;
105114 txBuilder . stakingContractAddress ( VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET ) ;
106115 txBuilder . stakingPeriod ( stakingPeriod ) ;
116+ txBuilder . amountToStake ( amountToStake ) ;
107117
108118 await txBuilder . build ( ) . should . be . rejectedWith ( 'Validator address is required' ) ;
109119 } ) ;
110120
121+ it ( 'should throw error when amount is missing' , async function ( ) {
122+ const txBuilder = createBasicTxBuilder ( ) ;
123+ txBuilder . stakingContractAddress ( VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET ) ;
124+ txBuilder . stakingPeriod ( stakingPeriod ) ;
125+ txBuilder . validator ( validatorAddress ) ;
126+
127+ await txBuilder . build ( ) . should . be . rejectedWith ( 'Staking amount is required' ) ;
128+ } ) ;
129+
130+ it ( 'should throw error when amount is less than minimum stake' , async function ( ) {
131+ const txBuilder = createBasicTxBuilder ( ) ;
132+ txBuilder . stakingContractAddress ( VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET ) ;
133+ txBuilder . stakingPeriod ( stakingPeriod ) ;
134+ txBuilder . validator ( validatorAddress ) ;
135+ txBuilder . amountToStake ( amountLessThanMinStake ) ;
136+
137+ await txBuilder . build ( ) . should . be . rejectedWith ( 'Staking amount must be between 25M and 600M VET' ) ;
138+ } ) ;
139+
140+ it ( 'should throw error when amount is greater than maximum stake' , async function ( ) {
141+ const txBuilder = createBasicTxBuilder ( ) ;
142+ txBuilder . stakingContractAddress ( VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET ) ;
143+ txBuilder . stakingPeriod ( stakingPeriod ) ;
144+ txBuilder . validator ( validatorAddress ) ;
145+ txBuilder . amountToStake ( amountGreaterThanMaxStake ) ;
146+
147+ await txBuilder . build ( ) . should . be . rejectedWith ( 'Staking amount must be between 25M and 600M VET' ) ;
148+ } ) ;
149+
111150 it ( 'should throw error when stakingContractAddress is invalid' , async function ( ) {
112151 const txBuilder = createBasicTxBuilder ( ) ;
113152
@@ -121,6 +160,7 @@ describe('VET Validator Registration Transaction', function () {
121160 const txBuilder = factory . getValidatorRegistrationBuilder ( ) ;
122161 txBuilder . stakingContractAddress ( VALIDATOR_REGISTRATION_STAKER_CONTRACT_ADDRESS_TESTNET ) ;
123162 txBuilder . stakingPeriod ( stakingPeriod ) ;
163+ txBuilder . amountToStake ( amountToStake ) ;
124164 txBuilder . chainTag ( 0x27 ) ;
125165 txBuilder . blockRef ( '0x0000000000000000' ) ;
126166 txBuilder . expiration ( 64 ) ;
@@ -151,6 +191,7 @@ describe('VET Validator Registration Transaction', function () {
151191 txBuilder . stakingPeriod ( stakingPeriod ) ;
152192 // Not setting chainTag
153193 txBuilder . blockRef ( '0x0000000000000000' ) ;
194+ txBuilder . amountToStake ( amountToStake ) ;
154195 txBuilder . expiration ( 64 ) ;
155196 txBuilder . gas ( 100000 ) ;
156197 txBuilder . gasPriceCoef ( 0 ) ;
@@ -184,6 +225,7 @@ describe('VET Validator Registration Transaction', function () {
184225 tx . stakingContractAddress . should . equal ( testData . VALIDATOR_REGISTRATION_STAKER_CONTRACT ) ;
185226 tx . stakingPeriod . should . equal ( testData . VALIDATOR_REGISTRATION_STAKING_PERIOD ) ;
186227 tx . validator . should . equal ( testData . VALIDATOR_REGISTRATION_VALIDATOR ) ;
228+ tx . amountToStake . should . equal ( testData . VALIDATOR_REGISTRATION_AMOUNT ) ;
187229 tx . validator . should . startWith ( '0x' ) ;
188230 tx . validator . should . equal ( tx . validator . toLowerCase ( ) ) ;
189231 should . exist ( tx . inputs ) ;
0 commit comments