@@ -42,6 +42,17 @@ var expectedInfo = abci.ResponseInfo{
4242
4343var mockTxProcessingTime = 10 * time .Millisecond
4444
45+ // TODO: accept argument for number of validators / proposer index
46+ func getRandomValidatorSet () * tmtypes.ValidatorSet {
47+ pubKey := ed25519 .GenPrivKey ().PubKey ()
48+ return & tmtypes.ValidatorSet {
49+ Proposer : & tmtypes.Validator {PubKey : pubKey , Address : pubKey .Address ()},
50+ Validators : []* tmtypes.Validator {
51+ {PubKey : pubKey , Address : pubKey .Address ()},
52+ },
53+ }
54+ }
55+
4556func TestConnectionGetter (t * testing.T ) {
4657 assert := assert .New (t )
4758
@@ -400,14 +411,22 @@ func TestTx(t *testing.T) {
400411 mockApp .On ("InitChain" , mock .Anything ).Return (abci.ResponseInitChain {})
401412 key , _ , _ := crypto .GenerateEd25519Key (crand .Reader )
402413 signingKey , _ , _ := crypto .GenerateEd25519Key (crand .Reader )
414+
415+ vKeys := make ([]tmcrypto.PrivKey , 4 )
416+ genesisValidators := make ([]tmtypes.GenesisValidator , len (vKeys ))
417+ for i := 0 ; i < len (vKeys ); i ++ {
418+ vKeys [i ] = ed25519 .GenPrivKey ()
419+ genesisValidators [i ] = tmtypes.GenesisValidator {Address : vKeys [i ].PubKey ().Address (), PubKey : vKeys [i ].PubKey (), Power : int64 (i + 100 ), Name : fmt .Sprintf ("genesis validator #%d" , i )}
420+ }
421+
403422 node , err := newFullNode (context .Background (), config.NodeConfig {
404423 DALayer : "mock" ,
405424 Aggregator : true ,
406425 BlockManagerConfig : config.BlockManagerConfig {
407426 BlockTime : 1 * time .Second , // blocks must be at least 1 sec apart for adjacent headers to get verified correctly
408427 }},
409428 key , signingKey , abcicli .NewLocalClient (nil , mockApp ),
410- & tmtypes.GenesisDoc {ChainID : "test" },
429+ & tmtypes.GenesisDoc {ChainID : "test" , Validators : genesisValidators },
411430 log .TestingLogger ())
412431 require .NoError (err )
413432 require .NotNil (node )
@@ -750,6 +769,8 @@ func getRandomBlockWithProposer(height uint64, nTxs int, proposerAddr []byte) *t
750769 copy (lastCommitHash , tmprotoLC .Hash ().Bytes ())
751770 block .SignedHeader .Header .LastCommitHash = lastCommitHash
752771
772+ block .SignedHeader .Validators = getRandomValidatorSet ()
773+
753774 return block
754775}
755776
0 commit comments