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 16:06:20 +02:00 committed by GitHub
parent 5ce15cb963
commit 59c43cd047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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)