-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add local mode execution * Add unit tests * Add warning about confidential store * Add more info about conf store * Address feedback
- Loading branch information
Showing
5 changed files
with
225 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"io" | ||
"testing" | ||
|
||
suave_backends "github.com/ethereum/go-ethereum/suave/backends" | ||
"github.com/stretchr/testify/require" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func flagSet(t *testing.T, flags []cli.Flag) *flag.FlagSet { | ||
set := flag.NewFlagSet("test", flag.ContinueOnError) | ||
|
||
for _, f := range flags { | ||
if err := f.Apply(set); err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
set.SetOutput(io.Discard) | ||
return set | ||
} | ||
|
||
func TestForgeReadConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
ctx := cli.NewContext(nil, flagSet(t, forgeCommand.Flags), nil) | ||
|
||
// read context from config toml file | ||
ctx.Set("config", "./testdata/forge.toml") | ||
|
||
sCtx, err := readContext(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, sCtx.Backend.ExternalWhitelist, []string{"a", "b"}) | ||
require.Equal(t, sCtx.Backend.ConfidentialEthBackend.(*suave_backends.RemoteEthBackend).Endpoint(), "suave") | ||
|
||
// override the config if the flags are set | ||
ctx.Set("eth-backend", "http://localhost:8545") | ||
ctx.Set("whitelist", "c,d") | ||
|
||
sCtx, err = readContext(ctx) | ||
require.NoError(t, err) | ||
require.Equal(t, sCtx.Backend.ExternalWhitelist, []string{"c", "d"}) | ||
require.Equal(t, sCtx.Backend.ConfidentialEthBackend.(*suave_backends.RemoteEthBackend).Endpoint(), "http://localhost:8545") | ||
|
||
// set flags to null and use default values | ||
ctx = cli.NewContext(nil, flagSet(t, forgeCommand.Flags), nil) | ||
|
||
sCtx, err = readContext(ctx) | ||
require.NoError(t, err) | ||
require.Len(t, sCtx.Backend.ExternalWhitelist, 0) | ||
|
||
_, ok := sCtx.Backend.ConfidentialEthBackend.(*suave_backends.EthMock) | ||
require.True(t, ok) | ||
} |
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,6 @@ | ||
[profile.suave] | ||
whitelist = ["a", "b"] | ||
eth_backend = "suave" | ||
[profile.ci.fuzz] | ||
runs = 10_000 | ||
solc_version = "0.8.23" |
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