github.com/lino-network/lino@v0.6.11/test/proposal/proposal_test.go (about)

     1  package proposal
     2  
     3  // import (
     4  // 	"testing"
     5  // 	"time"
     6  
     7  // 	"github.com/lino-network/lino/param"
     8  // 	"github.com/lino-network/lino/test"
     9  // 	"github.com/lino-network/lino/types"
    10  // 	"github.com/lino-network/lino/x/proposal"
    11  // 	val "github.com/lino-network/lino/x/validator"
    12  // 	vote "github.com/lino-network/lino/x/vote"
    13  // 	"github.com/tendermint/tendermint/crypto/secp256k1"
    14  // )
    15  
    16  // func TestForceValidatorVote(t *testing.T) {
    17  // 	accountTransactionPriv := secp256k1.GenPrivKey()
    18  // 	accountAppPriv := secp256k1.GenPrivKey()
    19  // 	accountName := "newuser"
    20  // 	validatorPriv := secp256k1.GenPrivKey()
    21  
    22  // 	accountTransactionPriv2 := secp256k1.GenPrivKey()
    23  // 	accountAppPriv2 := secp256k1.GenPrivKey()
    24  // 	accountName2 := "newuser2"
    25  // 	validatorPriv2 := secp256k1.GenPrivKey()
    26  
    27  // 	baseT := time.Unix(0,0).Add(100 * time.Second)
    28  // 	baseTime := baseT.Unix()
    29  // 	lb := test.NewTestLinoBlockchain(t, test.DefaultNumOfVal, baseT)
    30  
    31  // 	totalLNO := types.LNO("1000000000")
    32  // 	depositLNO := types.LNO("3000000")
    33  
    34  // 	totalCoin, _ := types.LinoToCoin(totalLNO)
    35  // 	depositCoin, _ := types.LinoToCoin(depositLNO)
    36  
    37  // 	test.CreateAccount(t, accountName, lb, 0,
    38  // 		secp256k1.GenPrivKey(), accountTransactionPriv, accountAppPriv, totalLNO)
    39  
    40  // 	test.CreateAccount(t, accountName2, lb, 1,
    41  // 		secp256k1.GenPrivKey(), accountTransactionPriv2, accountAppPriv2, totalLNO)
    42  
    43  // 	voteDepositMsg := vote.NewStakeInMsg(accountName, depositLNO)
    44  // 	test.SignCheckDeliver(t, lb, voteDepositMsg, 0, true, accountTransactionPriv, baseTime)
    45  
    46  // 	valDepositMsg := val.NewValidatorDepositMsg(accountName, depositLNO, validatorPriv.PubKey(), "")
    47  // 	test.SignCheckDeliver(t, lb, valDepositMsg, 1, true, accountTransactionPriv, baseTime)
    48  
    49  // 	voteDepositMsg2 := vote.NewStakeInMsg(accountName2, depositLNO)
    50  // 	test.SignCheckDeliver(t, lb, voteDepositMsg2, 0, true, accountTransactionPriv2, baseTime)
    51  
    52  // 	valDepositMsg2 := val.NewValidatorDepositMsg(accountName2, depositLNO, validatorPriv2.PubKey(), "")
    53  // 	test.SignCheckDeliver(t, lb, valDepositMsg2, 1, true, accountTransactionPriv2, baseTime)
    54  
    55  // 	test.CheckOncallValidatorList(t, accountName, true, lb)
    56  // 	test.CheckOncallValidatorList(t, accountName2, true, lb)
    57  
    58  // 	desc := param.GlobalAllocationParam{
    59  // 		GlobalGrowthRate:         types.NewDecFromRat(98, 1000),
    60  // 		InfraAllocation:          types.NewDecFromRat(1, 100),
    61  // 		ContentCreatorAllocation: types.NewDecFromRat(1, 100),
    62  // 		DeveloperAllocation:      types.NewDecFromRat(1, 100),
    63  // 		ValidatorAllocation:      types.NewDecFromRat(97, 100),
    64  // 	}
    65  
    66  // 	changeAllocationMsg := proposal.NewChangeGlobalAllocationParamMsg(accountName, desc, "")
    67  // 	test.SignCheckDeliver(t, lb, changeAllocationMsg, 2, true, accountTransactionPriv, baseTime)
    68  
    69  // 	accBalance := totalCoin.Minus(depositCoin).Minus(depositCoin).Minus(types.NewCoinFromInt64(1 * types.Decimals))
    70  // 	test.CheckBalance(t, accountName, lb, accBalance.Minus(test.ChangeParamMinDeposit))
    71  // 	test.CheckBalance(t, accountName2, lb, accBalance)
    72  
    73  // 	test.SimulateOneBlock(lb, baseTime)
    74  // 	// let validator 1 vote and validator 2 not vote.
    75  // 	voteProposalMsg := proposal.NewVoteProposalMsg(accountName, int64(1), true)
    76  // 	test.SignCheckDeliver(t, lb, voteProposalMsg, 3, true, accountTransactionPriv, baseTime)
    77  
    78  // 	test.SimulateOneBlock(lb, baseTime+test.ProposalDecideSec+1)
    79  // 	test.SimulateOneBlock(lb, baseTime+(test.ProposalDecideSec+test.ParamChangeExecutionSec)+2)
    80  // 	test.CheckGlobalAllocation(t, lb, desc)
    81  
    82  // 	// check validator 2 has been punished for not voting
    83  // 	test.CheckValidatorDeposit(t, accountName, lb, depositCoin)
    84  // 	test.CheckValidatorDeposit(t, accountName2, lb, depositCoin.Minus(test.PenaltyMissVote))
    85  // }