Skip to content

Commit

Permalink
TestClassHashAt improved
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodeev committed May 26, 2024
1 parent e9fe044 commit 4f5585e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
32 changes: 13 additions & 19 deletions rpc/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
// - t: the testing object for running the test cases
// Returns:
//
// Todo: Is not yet implemented completely
//
// none
func TestClassAt(t *testing.T) {
testConfig := beforeEach(t)
Expand Down Expand Up @@ -143,6 +141,12 @@ func TestClassHashAt(t *testing.T) {
ExpectedClassHash: utils.TestHexToFelt(t, "0xdeadbeef"),
},
},
"devnet": {
{
ContractHash: utils.TestHexToFelt(t, "0x41A78E741E5AF2FEC34B695679BC6891742439F7AFB8484ECD7766661AD02BF"),
ExpectedClassHash: utils.TestHexToFelt(t, "0x7B3E05F48F0C69E4A65CE5E076A66271A527AFF2C34CE1083EC6E1526997A69"),
},
},
"testnet": {
// v0 contracts
{
Expand All @@ -168,27 +172,17 @@ func TestClassHashAt(t *testing.T) {
}[testEnv]

for _, test := range testSet {

require := require.New(t)
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
classhash, err := testConfig.provider.ClassHashAt(context.Background(), WithBlockTag("latest"), test.ContractHash)
if err != nil {
t.Fatal(err)
}
require.NoError(err)
require.NotEmpty(classhash, "should return a class")
require.Equal(test.ExpectedClassHash, classhash)

diff, err := spy.Compare(classhash, false)
if err != nil {
t.Fatal("expecting to match", err)
}
if diff != "FullMatch" {
if _, err := spy.Compare(classhash, true); err != nil {
log.Fatal(err)
}
t.Fatal("structure expecting to be FullMatch, instead", diff)
}
if classhash == nil {
t.Fatalf("should return a class, instead %v", classhash)
}
require.Equal(t, test.ExpectedClassHash, classhash)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")
}
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
// Requires a Mainnet Starknet JSON-RPC compliant node (e.g. pathfinder)
// (ref: https://github.com/eqlabs/pathfinder)
"mainnet": {
base: "http://localhost:9545/v0.2/rpc",
base: "https://free-rpc.nethermind.io/mainnet-juno",
},
// Requires a Testnet Starknet JSON-RPC compliant node (e.g. pathfinder)
// (ref: https://github.com/eqlabs/pathfinder)
Expand Down

0 comments on commit 4f5585e

Please sign in to comment.