fix proposal update handling (#7372)

Fix proposal update handling to update the consensus state with the new diversifier and timestamp. Add checks in the proposal update test to ensure the values provided in the header match. Did manual testing to ensure the test additions fails before updating the code to the correct behaviour.

Co-authored-by: Christopher Goes <cwgoes@pluranimity.org>
This commit is contained in:
colin axnér
2020-09-23 14:06:20 +00:00
committed by GitHub
co-authored by Christopher Goes
parent 5ce15cb963
commit 59c43cd047
2 changed files with 13 additions and 3 deletions
@@ -42,7 +42,9 @@ func (cs ClientState) CheckProposedHeaderAndUpdateState(
clientState := &cs
consensusState := &ConsensusState{
PublicKey: smHeader.NewPublicKey,
PublicKey: smHeader.NewPublicKey,
Diversifier: smHeader.NewDiversifier,
Timestamp: smHeader.Timestamp,
}
clientState.Sequence = smHeader.Sequence
@@ -58,9 +58,17 @@ func (suite *SoloMachineTestSuite) TestCheckProposedHeaderAndUpdateState() {
if tc.expPass {
suite.Require().NoError(err)
suite.Require().Equal(header.(*types.Header).GetPubKey(), consState.(*types.ConsensusState).GetPubKey())
smConsState, ok := consState.(*types.ConsensusState)
suite.Require().True(ok)
smHeader, ok := header.(*types.Header)
suite.Require().True(ok)
suite.Require().Equal(cs.(*types.ClientState).ConsensusState, consState)
suite.Require().Equal(header.GetHeight().GetEpochHeight(), cs.(*types.ClientState).Sequence)
suite.Require().Equal(smHeader.GetPubKey(), smConsState.GetPubKey())
suite.Require().Equal(smHeader.NewDiversifier, smConsState.Diversifier)
suite.Require().Equal(smHeader.Timestamp, smConsState.Timestamp)
suite.Require().Equal(smHeader.GetHeight().GetEpochHeight(), cs.(*types.ClientState).Sequence)
} else {
suite.Require().Error(err)
suite.Require().Nil(cs)