Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
add TestRequestExternalData
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattharat Wiriyakulnan committed May 29, 2020
1 parent 483afb1 commit 3ad2200
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion chain/x/oracle/types/exec_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func mockFreshEnv() *types.ExecEnv {
ibcInfo := types.NewIBCInfo("source_port", "source_channel")
rawRequestID := []types.ExternalID{1, 2, 3}
request := types.NewRequest(oracleScriptID, calldata, valAddresses, minCount, requestHeight, requestTime, clientID, &ibcInfo, rawRequestID)
env := types.NewExecEnv(request, int64(1581589770), 0)
env := types.NewExecEnv(request, int64(1581589770), 3)
return env
}
func TestGetMaxRawRequestDataSize(t *testing.T) {
Expand Down Expand Up @@ -181,6 +181,24 @@ func TestGetExternalData(t *testing.T) {
}

func TestRequestExternalData(t *testing.T) {
env := mockFreshEnv()
err := env.RequestExternalData(1, 0, []byte("CALLDATA1"))
require.NoError(t, err)
err = env.RequestExternalData(2, 1, []byte("CALLDATA2"))
require.NoError(t, err)
err = env.RequestExternalData(3, 0, []byte("CALLDATA3"))
require.NoError(t, err)

rawReq := env.GetRawRequests()
expectRawReq := []types.RawRequest{
types.NewRawRequest(0, 1, []byte("CALLDATA1")),
types.NewRawRequest(1, 2, []byte("CALLDATA2")),
types.NewRawRequest(0, 3, []byte("CALLDATA3")),
}
require.Equal(t, expectRawReq, rawReq)
}

func TestRequestExternalDataFail(t *testing.T) {
env := mockExecutionEnv()
calldata := []byte("CALLDATA")

Expand Down

0 comments on commit 3ad2200

Please sign in to comment.