Skip to content

Commit

Permalink
Merge branch 'main' into provider-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes authored Jun 12, 2024
2 parents 5af1a68 + 503b22b commit f3ed2ba
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 185 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main_ci_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ jobs:
#run: cd rpc && go test -timeout 1200s -v -env testnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://starknet-goerli.cartridge.gg/"
INTEGRATION_BASE: "https://free-rpc.nethermind.io/sepolia-juno"

# Test rpc on mainnet
- name: Test RPC with mainnet
run: echo "Skip for now - need public endpoint that follows rpc spec"
#run: cd rpc && go test -timeout 600s -v -env mainnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://starknet.cartridge.gg/"
INTEGRATION_BASE: "https://free-rpc.nethermind.io/mainnet-juno"

# Test Account on devnet
- name: Test Account on devnet
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ jobs:
#run: cd rpc && go test -timeout 1200s -v -env testnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://starknet-goerli.cartridge.gg/"
INTEGRATION_BASE: "https://free-rpc.nethermind.io/sepolia-juno"

# Test rpc on mainnet
- name: Test RPC with mainnet
run: echo "Skip for now - need public endpoint that follows rpc spec"
#run: cd rpc && go test -timeout 600s -v -env mainnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://starknet.cartridge.gg/"
INTEGRATION_BASE: "https://free-rpc.nethermind.io/mainnet-juno"
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
<img src="https://img.shields.io/badge/Documentation-Website-yellow"
height="50" />
</a>
<br><br>

#### :warning: `starknet.go` is currently under active development and is experiencing a rearchitecture. It will undergo breaking changes.

`starknet.go` will get your golang backends and WASM frontends to Starknet easily.
**starknet.go** will get your golang backends and WASM frontends to Starknet easily.
With simple abstractions for the Starknet RPC, account management and common
operations on the wallets. The package has excellent documentation for a smooth
0 to 1 experience.
Expand Down
33 changes: 10 additions & 23 deletions rpc/call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rpc

import (
"context"
"log"
"testing"

"github.com/NethermindEth/juno/core/felt"
Expand All @@ -15,10 +14,9 @@ import (
// It sets up different test scenarios and asserts the result of each scenario.
// The test scenarios include different contract addresses, entry point selectors,
// and expected results for different environments (devnet, mock, testnet, mainnet).
// The function uses a spy to monitor the calls made to the provider, and compares
// the output against the expected output. It also checks that the output is not empty
// and that it matches the expected pattern result. If any of the assertions fail,
// the test fails with an error.
// The function calls the provider, and compares the output against the expected output.
// It also checks that the output is not empty and that it matches the expected pattern result.
// If any of the assertions fail, the test fails with an error.
//
// Parameters:
// - t: the testing object for running the test cases
Expand Down Expand Up @@ -60,12 +58,12 @@ func TestCall(t *testing.T) {
"testnet": {
{
FunctionCall: FunctionCall{
ContractAddress: utils.TestHexToFelt(t, "0x029260ce936efafa6d0042bc59757a653e3f992b97960c1c4f8ccd63b7a90136"),
EntryPointSelector: utils.TestHexToFelt(t, "0x004c4fb1ab068f6039d5780c68dd0fa2f8742cceb3426d19667778ca7f3518a9"),
ContractAddress: utils.TestHexToFelt(t, "0x025633c6142D9CA4126e3fD1D522Faa6e9f745144aba728c0B3FEE38170DF9e7"),
EntryPointSelector: utils.GetSelectorFromNameFelt("name"),
Calldata: []*felt.Felt{},
},
BlockID: WithBlockTag("latest"),
ExpectedPatternResult: utils.TestHexToFelt(t, "0x12"),
ExpectedPatternResult: utils.TestHexToFelt(t, "0x506f736974696f6e"),
},
},
"mainnet": {
Expand All @@ -82,21 +80,10 @@ func TestCall(t *testing.T) {
}[testEnv]

for _, test := range testSet {
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
require := require.New(t)
output, err := testConfig.provider.Call(context.Background(), FunctionCall(test.FunctionCall), test.BlockID)
if err != nil {
t.Fatal(err)
}
if diff, err := spy.Compare(output, false); err != nil || diff != "FullMatch" {
if _, err := spy.Compare(output, true); err != nil {
log.Fatal(err)
}
t.Fatal("expecting to match", err)
}
if len(output) == 0 {
t.Fatal("should return an output")
}
require.Equal(t, test.ExpectedPatternResult, output[0])
require.NoError(err)
require.NotEmpty(output, "should return an output")
require.Equal(test.ExpectedPatternResult, output[0])
}
}
2 changes: 0 additions & 2 deletions rpc/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
func (provider *Provider) Class(ctx context.Context, blockID BlockID, classHash *felt.Felt) (ClassOutput, error) {
var rawClass map[string]any
if err := do(ctx, provider.c, "starknet_getClass", &rawClass, blockID, classHash); err != nil {

return nil, tryUnwrapToRPCErr(err, ErrClassHashNotFound, ErrBlockNotFound)
}

Expand All @@ -42,7 +41,6 @@ func (provider *Provider) Class(ctx context.Context, blockID BlockID, classHash
func (provider *Provider) ClassAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (ClassOutput, error) {
var rawClass map[string]any
if err := do(ctx, provider.c, "starknet_getClassAt", &rawClass, blockID, contractAddress); err != nil {

return nil, tryUnwrapToRPCErr(err, ErrContractNotFound, ErrBlockNotFound)
}
return typecastClassOutput(rawClass)
Expand Down
Loading

0 comments on commit f3ed2ba

Please sign in to comment.