mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 03:41:45 +00:00
consensus: adjust TestService_NextConsensus after dBFT upgrade
This commit is contained in:
parent
04de604afd
commit
0b352349eb
1 changed files with 16 additions and 4 deletions
|
@ -64,6 +64,14 @@ func TestNewWatchingService(t *testing.T) {
|
||||||
require.NotPanics(t, srv.Shutdown)
|
require.NotPanics(t, srv.Shutdown)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func collectBlock(t *testing.T, bc *core.Blockchain, srv *service) {
|
||||||
|
h := bc.BlockHeight()
|
||||||
|
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.Context.BlockIndex}) // Collect and add block to the chain.
|
||||||
|
header, err := bc.GetHeader(bc.GetHeaderHash(h + 1))
|
||||||
|
require.NoError(t, err)
|
||||||
|
srv.dbft.InitializeConsensus(0, header.Timestamp*nsInMs) // Init consensus manually at the next height, as we don't run the consensus service.
|
||||||
|
}
|
||||||
|
|
||||||
func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint32) (*service, *wallet.Account) {
|
func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint32) (*service, *wallet.Account) {
|
||||||
acc, err := wallet.NewAccountFromWIF(testchain.WIF(testchain.IDToOrder(0)))
|
acc, err := wallet.NewAccountFromWIF(testchain.WIF(testchain.IDToOrder(0)))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -91,7 +99,11 @@ func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint3
|
||||||
require.NoError(t, bc.PoolTx(tx))
|
require.NoError(t, bc.PoolTx(tx))
|
||||||
|
|
||||||
srv := newTestServiceWithChain(t, bc)
|
srv := newTestServiceWithChain(t, bc)
|
||||||
|
h := bc.BlockHeight()
|
||||||
srv.dbft.Start(0)
|
srv.dbft.Start(0)
|
||||||
|
header, err := bc.GetHeader(bc.GetHeaderHash(h + 1))
|
||||||
|
require.NoError(t, err)
|
||||||
|
srv.dbft.InitializeConsensus(0, header.Timestamp*nsInMs) // Init consensus manually at the next height, as we don't run the consensus service.
|
||||||
|
|
||||||
// Register new candidate.
|
// Register new candidate.
|
||||||
b.Reset()
|
b.Reset()
|
||||||
|
@ -106,11 +118,11 @@ func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint3
|
||||||
require.NoError(t, newAcc.SignTx(netmode.UnitTestNet, tx))
|
require.NoError(t, newAcc.SignTx(netmode.UnitTestNet, tx))
|
||||||
|
|
||||||
require.NoError(t, bc.PoolTx(tx))
|
require.NoError(t, bc.PoolTx(tx))
|
||||||
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.Context.BlockIndex})
|
collectBlock(t, bc, srv)
|
||||||
|
|
||||||
cfg := bc.GetConfig()
|
cfg := bc.GetConfig()
|
||||||
for i := srv.dbft.BlockIndex; !cfg.ShouldUpdateCommitteeAt(i + offset); i++ {
|
for i := srv.dbft.BlockIndex; !cfg.ShouldUpdateCommitteeAt(i + offset); i++ {
|
||||||
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.Context.BlockIndex})
|
collectBlock(t, bc, srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vote for new candidate.
|
// Vote for new candidate.
|
||||||
|
@ -127,7 +139,7 @@ func initServiceNextConsensus(t *testing.T, newAcc *wallet.Account, offset uint3
|
||||||
require.NoError(t, newAcc.SignTx(netmode.UnitTestNet, tx))
|
require.NoError(t, newAcc.SignTx(netmode.UnitTestNet, tx))
|
||||||
|
|
||||||
require.NoError(t, bc.PoolTx(tx))
|
require.NoError(t, bc.PoolTx(tx))
|
||||||
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex})
|
collectBlock(t, bc, srv)
|
||||||
|
|
||||||
return srv, acc
|
return srv, acc
|
||||||
}
|
}
|
||||||
|
@ -155,7 +167,7 @@ func TestService_NextConsensus(t *testing.T) {
|
||||||
// OnPersist <- update committee
|
// OnPersist <- update committee
|
||||||
// Block <-
|
// Block <-
|
||||||
|
|
||||||
srv.dbft.OnTimeout(timer.HV{Height: srv.dbft.BlockIndex})
|
collectBlock(t, bc, srv)
|
||||||
checkNextConsensus(t, bc, height+1, hash.Hash160(script))
|
checkNextConsensus(t, bc, height+1, hash.Hash160(script))
|
||||||
})
|
})
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue