From ba01754e1c6a58132bf124ad07999bee36e11a46 Mon Sep 17 00:00:00 2001 From: rianhughes Date: Tue, 26 Sep 2023 15:23:18 +0300 Subject: [PATCH] fix test pkg and rename to devnet --- .github/workflows/test_devnet.yml | 33 +++++++++++++++++++++++++++++++ contracts/contracts_test.go | 2 +- {test => devnet}/devnet.go | 0 {test => devnet}/devnet_test.go | 2 +- devnet/main_test.go | 28 ++++++++++++++++++++++++++ gateway/gateway_test.go | 2 +- gateway/starknet_test.go | 2 +- providers_test.go | 2 +- test/main_test.go | 33 ------------------------------- 9 files changed, 66 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/test_devnet.yml rename {test => devnet}/devnet.go (100%) rename {test => devnet}/devnet_test.go (91%) create mode 100644 devnet/main_test.go delete mode 100644 test/main_test.go diff --git a/.github/workflows/test_devnet.yml b/.github/workflows/test_devnet.yml new file mode 100644 index 00000000..1d6f9f48 --- /dev/null +++ b/.github/workflows/test_devnet.yml @@ -0,0 +1,33 @@ +name: rpc + +on: + push: + branches: + - '**' + tags-ignore: + - '**' + +jobs: + build: + runs-on: ubuntu-22.04 + + services: + devnet: + image: shardlabs/starknet-devnet:latest + ports: + - 5050:5050 + + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 + + - name: wait for devnet to be up... + run: ./.bin/devnet.sh + + # Test devnet pkg + - name: Test devnet on devnet + run: cd devnet && go test -timeout 600s -v . diff --git a/contracts/contracts_test.go b/contracts/contracts_test.go index cfdc9d13..8ca2489b 100644 --- a/contracts/contracts_test.go +++ b/contracts/contracts_test.go @@ -10,7 +10,7 @@ import ( "github.com/NethermindEth/juno/core/felt" starknetgo "github.com/NethermindEth/starknet.go" "github.com/NethermindEth/starknet.go/artifacts" - devtest "github.com/NethermindEth/starknet.go/test" + devtest "github.com/NethermindEth/starknet.go/devnet" "github.com/NethermindEth/starknet.go/types" "github.com/NethermindEth/starknet.go/utils" "github.com/joho/godotenv" diff --git a/test/devnet.go b/devnet/devnet.go similarity index 100% rename from test/devnet.go rename to devnet/devnet.go diff --git a/test/devnet_test.go b/devnet/devnet_test.go similarity index 91% rename from test/devnet_test.go rename to devnet/devnet_test.go index 4ec78d6b..806c93e5 100644 --- a/test/devnet_test.go +++ b/devnet/devnet_test.go @@ -32,7 +32,7 @@ func TestDevnet_FeeToken(t *testing.T) { if err != nil { t.Fatalf("Reading token should succeed, instead: %v", err) } - if token.Address.String() != "0x062230ea046a9a5fbc261ac77d03c8d41e5d442db2284587570ab46455fd2488" { + if token.Address.String() != DevNetETHAddress { t.Fatalf("devnet ETH address, instead %s", token.Address.String()) } } diff --git a/devnet/main_test.go b/devnet/main_test.go new file mode 100644 index 00000000..0fb633c8 --- /dev/null +++ b/devnet/main_test.go @@ -0,0 +1,28 @@ +package test + +import ( + "flag" + "os" + "testing" +) + +const ( + DevNetETHAddress = "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" +) + +// testConfiguration is a type that is used to configure tests +type testConfiguration struct { + base string +} + +var ( + // set the environment for the test, default: devnet + testEnv = "devnet" +) + +// TestMain is used to trigger the tests and, in that case, check for the environment to use. +func TestMain(m *testing.M) { + flag.StringVar(&testEnv, "env", "devnet", "set the test environment") + flag.Parse() + os.Exit(m.Run()) +} diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go index d95aaec8..5179b497 100644 --- a/gateway/gateway_test.go +++ b/gateway/gateway_test.go @@ -11,9 +11,9 @@ import ( "testing" starknetgo "github.com/NethermindEth/starknet.go" + test "github.com/NethermindEth/starknet.go/devnet" "github.com/NethermindEth/starknet.go/gateway" "github.com/NethermindEth/starknet.go/rpc" - "github.com/NethermindEth/starknet.go/test" "github.com/NethermindEth/starknet.go/types" "github.com/NethermindEth/starknet.go/utils" "github.com/joho/godotenv" diff --git a/gateway/starknet_test.go b/gateway/starknet_test.go index 5c2a0b08..21bccf9e 100644 --- a/gateway/starknet_test.go +++ b/gateway/starknet_test.go @@ -10,9 +10,9 @@ import ( "github.com/NethermindEth/juno/core/felt" "github.com/NethermindEth/starknet.go/artifacts" + devtest "github.com/NethermindEth/starknet.go/devnet" "github.com/NethermindEth/starknet.go/gateway" "github.com/NethermindEth/starknet.go/rpc" - devtest "github.com/NethermindEth/starknet.go/test" "github.com/NethermindEth/starknet.go/types" "github.com/NethermindEth/starknet.go/utils" ) diff --git a/providers_test.go b/providers_test.go index 50bcd733..a942cf93 100644 --- a/providers_test.go +++ b/providers_test.go @@ -14,9 +14,9 @@ import ( "github.com/NethermindEth/juno/core/felt" "github.com/NethermindEth/starknet.go/artifacts" + devtest "github.com/NethermindEth/starknet.go/devnet" "github.com/NethermindEth/starknet.go/gateway" "github.com/NethermindEth/starknet.go/rpc" - devtest "github.com/NethermindEth/starknet.go/test" "github.com/NethermindEth/starknet.go/types" ethrpc "github.com/ethereum/go-ethereum/rpc" "github.com/joho/godotenv" diff --git a/test/main_test.go b/test/main_test.go deleted file mode 100644 index cdb9cabe..00000000 --- a/test/main_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package test - -import ( - "flag" - "os" - "testing" -) - -const ( - DevNetETHAddress = "0x62230ea046a9a5fbc261ac77d03c8d41e5d442db2284587570ab46455fd2488" - TestNetETHAddress = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" - DevNetAccount032Address = "0x06bb9425718d801fd06f144abb82eced725f0e81db61d2f9f4c9a26ece46a829" - TestNetAccount032Address = "0x6ca4fdd437dffde5253ba7021ef7265c88b07789aa642eafda37791626edf00" - DevNetAccount040Address = "0x080dff79c6216ad300b872b73ff41e271c63f213f8a9dc2017b164befa53b9" - TestNetAccount040Address = "0x6cbfa37f409610fee26eeb427ed854b3a4b24580d9b9ef6c3e38db7b3f7322c" -) - -// testConfiguration is a type that is used to configure tests -type testConfiguration struct { - base string -} - -var ( - // set the environment for the test, default: devnet - testEnv = "devnet" -) - -// TestMain is used to trigger the tests and, in that case, check for the environment to use. -func TestMain(m *testing.M) { - flag.StringVar(&testEnv, "env", "devnet", "set the test environment") - flag.Parse() - os.Exit(m.Run()) -}