forked from cosmos/gravity-bridge
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #285 from althea-net/christianborst/oracle-event-e…
…ndpoint Adding oracle attestations endpoint
- Loading branch information
Showing
20 changed files
with
955 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package keeper | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/althea-net/cosmos-gravity-bridge/module/x/gravity/types" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
sdktypes "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// Sets up 10 attestations and checks that they are returned in the correct order | ||
func TestGetMostRecentAttestations(t *testing.T) { | ||
input := CreateTestEnv(t) | ||
k := input.GravityKeeper | ||
ctx := input.Context | ||
|
||
lenth := 10 | ||
msgs := make([]types.MsgSendToCosmosClaim, 0, lenth) | ||
anys := make([]codectypes.Any, 0, lenth) | ||
for i := 0; i < lenth; i++ { | ||
nonce := uint64(1 + i) | ||
msg := types.MsgSendToCosmosClaim{ | ||
EventNonce: nonce, | ||
BlockHeight: 1, | ||
TokenContract: "0x00000000000000000001", | ||
Amount: sdktypes.NewInt(10000000000 + int64(i)), | ||
EthereumSender: "0x00000000000000000002", | ||
CosmosReceiver: "0x00000000000000000003", | ||
Orchestrator: "0x00000000000000000004", | ||
} | ||
msgs = append(msgs, msg) | ||
|
||
any, _ := codectypes.NewAnyWithValue(&msg) | ||
anys = append(anys, *any) | ||
att := &types.Attestation{ | ||
Observed: false, | ||
Height: uint64(ctx.BlockHeight()), | ||
Claim: any, | ||
} | ||
k.SetAttestation(ctx, nonce, msg.ClaimHash(), att) | ||
} | ||
|
||
recentAttestations := k.GetMostRecentAttestations(ctx, uint64(10)) | ||
require.True(t, len(recentAttestations) == lenth, | ||
"recentAttestations should have len %v but instead has %v", lenth, len(recentAttestations)) | ||
for n, attest := range recentAttestations { | ||
require.Equal(t, attest.Claim.GetCachedValue(), anys[n].GetCachedValue(), | ||
"The %vth claim does not match our message: claim %v\n message %v", n, attest.Claim, msgs[n]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.