Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmel committed Feb 22, 2024
1 parent 8bcaa99 commit 375f030
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions suave/e2e/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,39 @@ func TestE2ERemoteCalls(t *testing.T) {
})
}

func TestE2ERemoteCallsWithDns(t *testing.T) {
httpSrv := httptest.NewServer(&dummyRelayer{fn: func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte{0x1, 0x2, 0x3})
}})
defer httpSrv.Close()

fr := newFramework(t, WithDnsRegistry(map[string]string{"goerli": httpSrv.URL}))
defer fr.Close()

clt := fr.NewSDKClient()

contractAddr := common.Address{0x3}
contract := sdk.GetContract(contractAddr, exampleCallSourceContract.Abi, clt)

t.Run("DNS registered", func(t *testing.T) {
req := &types.HttpRequest{
Method: "GET",
Url: "goerli",
}
_, err := contract.SendTransaction("remoteCall", []interface{}{req}, nil)
require.NoError(t, err)
})

t.Run("DNS not registered", func(t *testing.T) {
req := &types.HttpRequest{
Method: "GET",
Url: "sepolia",
}
_, err := contract.SendTransaction("remoteCall", []interface{}{req}, nil)
require.Error(t, err)
})
}

func TestE2EPrecompile_Builder(t *testing.T) {
fr := newFramework(t, WithKettleAddress())
defer fr.Close()
Expand Down Expand Up @@ -1406,6 +1439,12 @@ func WithWhitelist(whitelist []string) frameworkOpt {
}
}

func WithDnsRegistry(registry map[string]string) frameworkOpt {
return func(c *frameworkConfig) {
c.suaveConfig.SuaveDnsRegistry = registry
}
}

func newFramework(t *testing.T, opts ...frameworkOpt) *framework {
cfg := defaultFrameworkConfig
for _, opt := range opts {
Expand Down

0 comments on commit 375f030

Please sign in to comment.