Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Jul 4, 2024
1 parent c146b09 commit 0afcdb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion e2etest/contract_staking_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestContractStakingV2(t *testing.T) {
act: &actionWithTime{mustNoErr(action.SignedExecution(contractAddress, identityset.PrivateKey(stakerID), test.nonceMgr.pop(identityset.Address(stakerID).String()), stakeAmount, gasLimit, gasPrice, mustCallData("stake(uint256,address)", stakeDurationBlocks, common.BytesToAddress(identityset.Address(candOwnerID).Bytes())), action.WithChainID(chainID))), stakeTime},
expect: []actionExpect{successExpect,
&bucketExpect{&iotextypes.VoteBucket{Index: 1, ContractAddress: contractAddress, Owner: identityset.Address(stakerID).String(), CandidateAddress: identityset.Address(candOwnerID).String(), StakedDuration: uint32(stakeDurationBlocks.Uint64() / uint64(blocksPerDay)), StakedDurationBlockNumber: stakeDurationBlocks.Uint64(), CreateTime: timestamppb.New(time.Time{}), StakeStartTime: timestamppb.New(time.Time{}), StakeStartBlockHeight: 3, CreateBlockHeight: 3, UnstakeStartTime: timestamppb.New(time.Time{}), UnstakeStartBlockHeight: uint64(math.MaxUint64), StakedAmount: stakeAmount.String(), AutoStake: true}},
&candidateExpect{"cand1", &iotextypes.CandidateV2{OwnerAddress: identityset.Address(candOwnerID).String(), OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), Name: "cand1", TotalWeightedVotes: "1256001586604779503009155", SelfStakingTokens: registerAmount.String(), SelfStakeBucketIdx: 0}},
&candidateExpect{"cand1", &iotextypes.CandidateV2{OwnerAddress: identityset.Address(candOwnerID).String(), Id: identityset.Address(candOwnerID).String(), OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), Name: "cand1", TotalWeightedVotes: "1256001586604779503009155", SelfStakingTokens: registerAmount.String(), SelfStakeBucketIdx: 0}},
&functionExpect{func(test *e2etest, act *action.SealedEnvelope, receipt *action.Receipt, err error) {
candidate, err := test.getCandidateByName("cand1")
require.NoError(err)
Expand Down
10 changes: 5 additions & 5 deletions e2etest/native_staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ func TestCandidateTransferOwnership(t *testing.T) {
{mustNoErr(action.SignedCandidateActivate(test.nonceMgr.pop(identityset.Address(oldOwnerID).String()), 1, gasLimit, gasPrice, identityset.PrivateKey(oldOwnerID), action.WithChainID(chainID))), time.Now()},
},
act: &actionWithTime{mustNoErr(action.SignedCandidateTransferOwnership(test.nonceMgr.pop(identityset.Address(oldOwnerID).String()), identityset.Address(newOwnerID).String(), nil, gasLimit, gasPrice, identityset.PrivateKey(oldOwnerID), action.WithChainID(chainID))), time.Now()},
expect: []actionExpect{successExpect, &candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "2491242816406174220844604", SelfStakingTokens: registerAmount.String(), OwnerAddress: identityset.Address(newOwnerID).String(), SelfStakeBucketIdx: 1}}},
expect: []actionExpect{successExpect, &candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", Id: identityset.Address(oldOwnerID).String(), OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "2491242816406174220844604", SelfStakingTokens: registerAmount.String(), OwnerAddress: identityset.Address(newOwnerID).String(), SelfStakeBucketIdx: 1}}},
},
})
})
Expand Down Expand Up @@ -1195,7 +1195,7 @@ func TestCandidateTransferOwnership(t *testing.T) {
},
act: &actionWithTime{mustNoErr(action.SignedDepositToStake(test.nonceMgr.pop(identityset.Address(stakerID).String()), 1, unit.ConvertIotxToRau(10000000).String(), nil, gasLimit, gasPrice, identityset.PrivateKey(stakerID), action.WithChainID(chainID))), time.Now()},
expect: []actionExpect{successExpect,
&candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "15734989908573124317570090", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID).String(), SelfStakeBucketIdx: math.MaxUint64}},
&candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", Id: identityset.Address(candOwnerID).String(), OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "15734989908573124317570090", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID).String(), SelfStakeBucketIdx: math.MaxUint64}},
&bucketExpect{&iotextypes.VoteBucket{Index: 1, EndorsementExpireBlockHeight: 10, CandidateAddress: identityset.Address(candOwnerID).String(), StakedAmount: "11200000000000000000000000", AutoStake: true, StakedDuration: 91, Owner: identityset.Address(stakerID).String(), CreateTime: timestamppb.New(stakeTime), StakeStartTime: timestamppb.New(stakeTime), UnstakeStartTime: &timestamppb.Timestamp{}}},
},
},
Expand All @@ -1207,7 +1207,7 @@ func TestCandidateTransferOwnership(t *testing.T) {
},
act: &actionWithTime{mustNoErr(action.SignedChangeCandidate(test.nonceMgr.pop(identityset.Address(stakerID).String()), "cand2", 1, nil, gasLimit, gasPrice, identityset.PrivateKey(stakerID), action.WithChainID(chainID))), time.Now()},
expect: []actionExpect{successExpect,
&candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "92550969839127272820178", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID).String(), SelfStakeBucketIdx: math.MaxUint64}},
&candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", Id: identityset.Address(candOwnerID).String(), OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "92550969839127272820178", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID).String(), SelfStakeBucketIdx: math.MaxUint64}},
},
},
{
Expand All @@ -1225,7 +1225,7 @@ func TestCandidateTransferOwnership(t *testing.T) {
},
act: &actionWithTime{mustNoErr(action.SignedTransfer(identityset.Address(1).String(), identityset.PrivateKey(2), test.nonceMgr.pop(identityset.Address(2).String()), unit.ConvertIotxToRau(1), nil, gasLimit, gasPrice, action.WithChainID(chainID))), time.Now()},
expect: []actionExpect{successExpect,
&candidateExpect{"cand3", &iotextypes.CandidateV2{Name: "cand3", OperatorAddress: identityset.Address(4).String(), RewardAddress: identityset.Address(4).String(), TotalWeightedVotes: "2880688542027669019063296", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID3).String(), SelfStakeBucketIdx: math.MaxUint64}},
&candidateExpect{"cand3", &iotextypes.CandidateV2{Name: "cand3", Id: identityset.Address(candOwnerID3).String(), OperatorAddress: identityset.Address(4).String(), RewardAddress: identityset.Address(4).String(), TotalWeightedVotes: "2880688542027669019063296", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID3).String(), SelfStakeBucketIdx: math.MaxUint64}},
&bucketExpect{&iotextypes.VoteBucket{Index: 4, EndorsementExpireBlockHeight: 24, CandidateAddress: identityset.Address(candOwnerID3).String(), StakedAmount: "1200000000000000000000000", AutoStake: true, StakedDuration: 91, Owner: identityset.Address(stakerID).String(), CreateTime: timestamppb.New(stakeTime), StakeStartTime: timestamppb.New(stakeTime), UnstakeStartTime: &timestamppb.Timestamp{}}},
},
},
Expand All @@ -1235,7 +1235,7 @@ func TestCandidateTransferOwnership(t *testing.T) {
expect: []actionExpect{successExpect,
&bucketExpect{&iotextypes.VoteBucket{Index: 1, EndorsementExpireBlockHeight: 10, CandidateAddress: identityset.Address(candOwnerID2).String(), StakedAmount: "11200000000000000000000000", AutoStake: true, StakedDuration: 91, Owner: identityset.Address(stakerID).String(), CreateTime: timestamppb.New(stakeTime), StakeStartTime: timestamppb.New(stakeTime), UnstakeStartTime: &timestamppb.Timestamp{}}},
&bucketExpect{&iotextypes.VoteBucket{Index: 4, EndorsementExpireBlockHeight: 0, CandidateAddress: identityset.Address(candOwnerID3).String(), StakedAmount: "1200000000000000000000000", AutoStake: true, StakedDuration: 91, Owner: identityset.Address(stakerID).String(), CreateTime: timestamppb.New(stakeTime), StakeStartTime: timestamppb.New(stakeTime), UnstakeStartTime: &timestamppb.Timestamp{}}},
&candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "0", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID).String(), SelfStakeBucketIdx: math.MaxUint64}},
&candidateExpect{"cand1", &iotextypes.CandidateV2{Name: "cand1", Id: identityset.Address(candOwnerID).String(), OperatorAddress: identityset.Address(1).String(), RewardAddress: identityset.Address(1).String(), TotalWeightedVotes: "0", SelfStakingTokens: "0", OwnerAddress: identityset.Address(candOwnerID).String(), SelfStakeBucketIdx: math.MaxUint64}},
},
},
})
Expand Down

0 comments on commit 0afcdb0

Please sign in to comment.