From 6d831f77a83f945dc9181c52e70c69a20956c5aa Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 5 Jul 2024 12:05:04 +0200 Subject: [PATCH] fix: failing tests --- .../tokenomics/relay_mining_difficulty_test.go | 16 +++++++++++----- x/proof/keeper/msg_server_submit_proof_test.go | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/integration/tokenomics/relay_mining_difficulty_test.go b/tests/integration/tokenomics/relay_mining_difficulty_test.go index 8eb6a57c8..1b543c00a 100644 --- a/tests/integration/tokenomics/relay_mining_difficulty_test.go +++ b/tests/integration/tokenomics/relay_mining_difficulty_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" + "github.com/pokt-network/poktroll/pkg/crypto/protocol" testutilevents "github.com/pokt-network/poktroll/testutil/events" "github.com/pokt-network/poktroll/testutil/integration" testutil "github.com/pokt-network/poktroll/testutil/integration" @@ -28,7 +29,7 @@ func init() { } func TestUpdateRelayMiningDifficulty_NewServiceSeenForTheFirstTime(t *testing.T) { - var claimWindowOpenBlockHash, proofWindowOpenBlockHash []byte + var claimWindowOpenBlockHash, proofWindowOpenBlockHash, proofPathSeedBlockHash []byte // Create a new integration app integrationApp := integration.NewCompleteIntegrationApp(t) @@ -89,7 +90,7 @@ func TestUpdateRelayMiningDifficulty_NewServiceSeenForTheFirstTime(t *testing.T) createProofMsg := prooftypes.MsgSubmitProof{ SupplierAddress: integrationApp.DefaultSupplier.Address, SessionHeader: session.Header, - Proof: getProof(t, trie), + Proof: getProof(t, trie, proofPathSeedBlockHash, session.GetHeader().GetSessionId()), } result = integrationApp.RunMsg(t, &createProofMsg, @@ -202,11 +203,16 @@ func prepareSMST( // getProof returns a proof for the given session for the empty path. // If there is only one relay in the trie, the proof will be for that single // relay since it is "closest" to any path provided, empty or not. -func getProof(t *testing.T, trie *smt.SMST) []byte { +func getProof( + t *testing.T, + trie *smt.SMST, + pathSeedBlockHash []byte, + sessionId string, +) []byte { t.Helper() - emptyPath := make([]byte, trie.PathHasherSize()) - proof, err := trie.ProveClosest(emptyPath) + path := protocol.GetPathForProof(pathSeedBlockHash, sessionId) + proof, err := trie.ProveClosest(path) require.NoError(t, err) proofBz, err := proof.Marshal() diff --git a/x/proof/keeper/msg_server_submit_proof_test.go b/x/proof/keeper/msg_server_submit_proof_test.go index 2ef7cb9d4..4e12482be 100644 --- a/x/proof/keeper/msg_server_submit_proof_test.go +++ b/x/proof/keeper/msg_server_submit_proof_test.go @@ -138,6 +138,8 @@ func TestMsgServer_SubmitProof_Success(t *testing.T) { // will be part of the session. sessionHeader := keepers.GetSessionHeader(ctx, t, appAddr, service, 1) + expectedMerkleProofPath := protocol.GetPathForProof(blockHeaderHash, sessionHeader.GetSessionId()) + // Construct a proof message server from the proof keeper. srv := keeper.NewMsgServerImpl(*keepers.Keeper)