From 375f0307fa8f61a78750572f14038ce1d79695ca Mon Sep 17 00:00:00 2001 From: Jinsuk Park Date: Wed, 21 Feb 2024 16:56:09 -0800 Subject: [PATCH] add e2e test --- suave/e2e/workflow_test.go | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/suave/e2e/workflow_test.go b/suave/e2e/workflow_test.go index a6904c8be..4294ace89 100644 --- a/suave/e2e/workflow_test.go +++ b/suave/e2e/workflow_test.go @@ -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() @@ -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 {