Skip to content

Commit

Permalink
Merge branch 'main' into transaction-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed May 13, 2024
2 parents 7a3f264 + 177f00e commit 852364f
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main_ci_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

services:
devnet:
image: shardlabs/starknet-devnet:latest
image: shardlabs/starknet-devnet-rs:0.0.5
ports:
- 5050:5050

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

services:
devnet:
image: shardlabs/starknet-devnet:0.3.4
image: shardlabs/starknet-devnet-rs:0.0.5
ports:
- 5050:5050

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_account.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

services:
devnet:
image: shardlabs/starknet-devnet:0.5.5
image: shardlabs/starknet-devnet-rs:0.0.5
ports:
- 5050:5050

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

services:
devnet:
image: shardlabs/starknet-devnet:latest
image: shardlabs/starknet-devnet-rs:0.0.5
ports:
- 5050:5050

Expand Down
20 changes: 14 additions & 6 deletions devnet/devnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ func (devnet *DevNet) api(uri string) string {
// the list of accounts and any error that occurred during the process.
//
// Parameters:
// none
//
// none
//
// Returns:
// - []TestAccount: a slice of TestAccount structs
func (devnet *DevNet) Accounts() ([]TestAccount, error) {
Expand All @@ -87,9 +89,12 @@ func (devnet *DevNet) Accounts() ([]TestAccount, error) {
// and false otherwise.
//
// Parameters:
// none
//
// none
//
// Returns:
// bool: true if the DevNet is alive, false otherwise
//
// bool: true if the DevNet is alive, false otherwise
func (devnet *DevNet) IsAlive() bool {
req, err := http.NewRequest(http.MethodGet, devnet.api("/is_alive"), nil)
if err != nil {
Expand All @@ -107,8 +112,9 @@ func (devnet *DevNet) IsAlive() bool {
}

type MintResponse struct {
NewBalance *big.Int `json:"new_balance"`
Unit string `json:"unit"`
NewBalance string `json:"new_balance"`
Unit string `json:"unit"`
TransactionHash string `json:"tx_hash"`
}

// Mint mints a certain amount of tokens for a given address.
Expand Down Expand Up @@ -160,7 +166,9 @@ type FeeToken struct {
// to retrieve the fee token.
//
// Parameters:
// none
//
// none
//
// Returns:
// - *FeeToken: a pointer to a FeeToken object
// - error: an error, if any
Expand Down
38 changes: 12 additions & 26 deletions devnet/devnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package devnet

import (
"math/big"
"strconv"
"strings"
"testing"

Expand All @@ -16,7 +17,8 @@ import (
// Parameters:
// - t: is the testing.T instance for running the test
// Returns:
// none
//
// none
func TestDevnet_IsAlive(t *testing.T) {
d := NewDevNet()
if !d.IsAlive() {
Expand All @@ -30,9 +32,11 @@ func TestDevnet_IsAlive(t *testing.T) {
// account addresses are valid.
//
// Parameters:
// - t: is the testing.T instance for running the test
// - t: is the testing.T instance for running the test
//
// Returns:
// none
//
// none
func TestDevnet_Accounts(t *testing.T) {
d := NewDevNet()
accounts, err := d.Accounts()
Expand All @@ -44,26 +48,6 @@ func TestDevnet_Accounts(t *testing.T) {
}
}

// TestDevnet_FeeToken tests the FeeToken function of the Devnet struct.
//
// The function retrieves the fee token from the Devnet instance and checks that
// it matches the expected ETH address.
//
// Parameters:
// - t: is the testing.T instance for running the test
// Returns:
// none
func TestDevnet_FeeToken(t *testing.T) {
d := NewDevNet()
token, err := d.FeeToken()
if err != nil {
t.Fatalf("Reading token should succeed, instead: %v", err)
}
if token.Address.String() != DevNetETHAddress {
t.Fatalf("devnet ETH address, instead %s", token.Address.String())
}
}

// TestDevnet_Mint is a test function that tests the Mint method of the Devnet struct.
//
// It initializes a new Devnet instance and sets the amount to 1000000000000000000.
Expand All @@ -74,15 +58,17 @@ func TestDevnet_FeeToken(t *testing.T) {
// Parameters:
// - t: is the testing.T instance for running the test
// Returns:
// none
//
// none
func TestDevnet_Mint(t *testing.T) {
d := NewDevNet()
amount := big.NewInt(int64(1000000000000000000))
resp, err := d.Mint(utils.TestHexToFelt(t, "0x1"), amount)
if err != nil {
t.Fatalf("Minting ETH should succeed, instead: %v", err)
}
if resp.NewBalance.Cmp(amount) < 0 {
t.Fatalf("ETH should be higher than the last mint, instead: %d", resp.NewBalance)
balance, _ := (strconv.ParseInt(resp.NewBalance, 10, 64))
if balance < 0 {
t.Fatalf("ETH should be higher than the last mint, instead: %d", balance)
}
}
6 changes: 3 additions & 3 deletions rpc/call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func TestCall(t *testing.T) {
{
FunctionCall: FunctionCall{
// ContractAddress of predeployed devnet Feetoken
ContractAddress: utils.TestHexToFelt(t, "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"),
EntryPointSelector: utils.GetSelectorFromNameFelt("name"),
ContractAddress: utils.TestHexToFelt(t, DevNetETHAddress),
EntryPointSelector: utils.GetSelectorFromNameFelt("decimals"),
Calldata: []*felt.Felt{},
},
BlockID: WithBlockTag("latest"),
ExpectedPatternResult: utils.TestHexToFelt(t, "0x6574686572"),
ExpectedPatternResult: utils.TestHexToFelt(t, "0x12"),
},
},
"mock": {
Expand Down
4 changes: 2 additions & 2 deletions rpc/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func mock_starknet_chainId(result interface{}, method string, args ...interface{
if len(args) != 0 {
return errWrongArgs
}
value := "0x534e5f474f45524c49"
value := "0x534e5f5345504f4c4941"
*r = value
return nil
}
Expand Down Expand Up @@ -544,7 +544,7 @@ func mock_starknet_getEvents(result interface{}, method string, args ...interfac
events :=
EventChunk{
Events: []EmittedEvent{
EmittedEvent{
{
BlockHash: blockHash,
BlockNumber: 1472,
TransactionHash: txHash,
Expand Down
16 changes: 8 additions & 8 deletions rpc/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

const (
TestPublicKey = "0x783318b2cc1067e5c06d374d2bb9a0382c39aabd009b165d7a268b882971d6"
DevNetETHAddress = "0x62230ea046a9a5fbc261ac77d03c8d41e5d442db2284587570ab46455fd2488"
DevNetETHAddress = "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
TestNetETHAddress = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
DevNetAccount032Address = "0x06bb9425718d801fd06f144abb82eced725f0e81db61d2f9f4c9a26ece46a829"
TestNetAccount032Address = "0x6ca4fdd437dffde5253ba7021ef7265c88b07789aa642eafda37791626edf00"
Expand Down Expand Up @@ -101,7 +101,7 @@ func beforeEach(t *testing.T) *testConfiguration {
return &testConfig
}

testConfig.base = "https://starknet-goerli.cartridge.gg"
testConfig.base = "https://free-rpc.nethermind.io/sepolia-juno"
base := os.Getenv("INTEGRATION_BASE")
if base != "" {
testConfig.base = base
Expand Down Expand Up @@ -137,10 +137,10 @@ func TestChainID(t *testing.T) {
ChainID string
}
testSet := map[string][]testSetType{
"devnet": {{ChainID: "SN_GOERLI"}},
"devnet": {{ChainID: "SN_SEPOLIA"}},
"mainnet": {{ChainID: "SN_MAIN"}},
"mock": {{ChainID: "SN_GOERLI"}},
"testnet": {{ChainID: "SN_GOERLI"}},
"mock": {{ChainID: "SN_SEPOLIA"}},
"testnet": {{ChainID: "SN_SEPOLIA"}},
}[testEnv]

for _, test := range testSet {
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestSyncing(t *testing.T) {
"devnet": {},
"mainnet": {{ChainID: "SN_MAIN"}},
"mock": {{ChainID: "MOCK"}},
"testnet": {{ChainID: "SN_GOERLI"}},
"testnet": {{ChainID: "SN_SEPOLIA"}},
}[testEnv]

for range testSet {
Expand Down Expand Up @@ -305,9 +305,9 @@ func TestCookieManagement(t *testing.T) {

resp, err = client.ChainID(context.Background())
require.Nil(t, err)
require.Equal(t, resp, "SN_GOERLI")
require.Equal(t, resp, "SN_SEPOLIA")

resp, err = client.ChainID(context.Background())
require.Nil(t, err)
require.Equal(t, resp, "SN_GOERLI")
require.Equal(t, resp, "SN_SEPOLIA")
}

0 comments on commit 852364f

Please sign in to comment.