Skip to content

Commit

Permalink
chore: fix thelper for state
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Aug 21, 2023
1 parent 2c9d264 commit 39429ae
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func setup(t *testing.T) *testData {
func (td *testData) makeBlockAndCertificate(t *testing.T, round int16,
signers ...crypto.Signer,
) (*block.Block, *block.Certificate) {
t.Helper()
var st *state
if td.state1.committee.IsProposer(td.state1.signers[0].Address(), round) {
st = td.state1
Expand All @@ -129,6 +130,7 @@ func (td *testData) makeBlockAndCertificate(t *testing.T, round int16,
func (td *testData) makeCertificateAndSign(t *testing.T, blockHash hash.Hash, round int16,
signers ...crypto.Signer,
) *block.Certificate {
t.Helper()
assert.NotZero(t, len(signers))
sigs := make([]*bls.Signature, len(signers))
sb := block.CertificateSignBytes(blockHash, round)
Expand Down Expand Up @@ -159,13 +161,15 @@ func (td *testData) makeCertificateAndSign(t *testing.T, blockHash hash.Hash, ro
}

func (td *testData) commitBlockForAllStates(t *testing.T, b *block.Block, c *block.Certificate) {
t.Helper()
assert.NoError(t, td.state1.CommitBlock(td.state1.lastInfo.BlockHeight()+1, b, c))
assert.NoError(t, td.state2.CommitBlock(td.state2.lastInfo.BlockHeight()+1, b, c))
assert.NoError(t, td.state3.CommitBlock(td.state3.lastInfo.BlockHeight()+1, b, c))
assert.NoError(t, td.state4.CommitBlock(td.state4.lastInfo.BlockHeight()+1, b, c))
}

func (td *testData) moveToNextHeightForAllStates(t *testing.T) {
t.Helper()
b, c := td.makeBlockAndCertificate(t, 0, td.valSigner1, td.valSigner2, td.valSigner3, td.valSigner4)
td.commitBlockForAllStates(t, b, c)
}
Expand Down

0 comments on commit 39429ae

Please sign in to comment.