Skip to content

Commit

Permalink
Merge branch 'main' into call-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes authored May 16, 2024
2 parents d29e4aa + c76fd3f commit 2fffbef
Show file tree
Hide file tree
Showing 18 changed files with 753 additions and 681 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
7 changes: 3 additions & 4 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,10 +970,9 @@ func TestWaitForTransactionReceiptMOCK(t *testing.T) {
Hash: new(felt.Felt).SetUint64(2),
ShouldCallTransactionReceipt: true,
ExpectedReceipt: &rpc.TransactionReceiptWithBlockInfo{
TransactionReceipt: rpc.InvokeTransactionReceipt{
TransactionHash: new(felt.Felt).SetUint64(2),
ExecutionStatus: rpc.TxnExecutionStatusSUCCEEDED,
},
UnknownTransactionReceipt: rpc.UnknownTransactionReceipt{},
BlockHash: new(felt.Felt).SetUint64(2),
BlockNumber: 2,
},

ExpectedErr: nil,
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)
}
}
Loading

0 comments on commit 2fffbef

Please sign in to comment.