Skip to content

Commit

Permalink
Removing spy from call and contract tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodeev committed May 28, 2024
1 parent aef6881 commit f9fc2bd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 49 deletions.
8 changes: 0 additions & 8 deletions rpc/call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,9 @@ func TestCall(t *testing.T) {

for _, test := range testSet {
require := require.New(t)

spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
output, err := testConfig.provider.Call(context.Background(), FunctionCall(test.FunctionCall), test.BlockID)
require.NoError(err)
require.NotEmpty(output, "should return an output")

diff, err := spy.Compare(output, false)
require.NoError(err)
require.Equal(diff, "FullMatch", "expecting to match")

require.Equal(test.ExpectedPatternResult, output[0])
}
}
41 changes: 0 additions & 41 deletions rpc/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,11 @@ func TestClassAt(t *testing.T) {

for _, test := range testSet {
require := require.New(t)
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
resp, err := testConfig.provider.ClassAt(context.Background(), test.Block, test.ContractAddress)
require.NoError(err)

switch class := resp.(type) {
case *DeprecatedContractClass:
diff, err := spy.Compare(class, false)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")
require.NotEmpty(class.Program, "code should exist")

require.Condition(func() bool {
Expand All @@ -93,9 +88,6 @@ func TestClassAt(t *testing.T) {
return false
}, "operation not found in the class")
case *ContractClass:
diff, err := spy.Compare(class, false)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")
require.NotEmpty(class.SierraProgram, "code should exist")

require.Condition(func() bool {
Expand Down Expand Up @@ -172,16 +164,10 @@ func TestClassHashAt(t *testing.T) {

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)
require.NoError(err)
require.NotEmpty(classhash, "should return a class")
require.Equal(test.ExpectedClassHash, classhash)

diff, err := spy.Compare(classhash, false)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")
}
}

Expand Down Expand Up @@ -265,24 +251,15 @@ func TestClass(t *testing.T) {

for _, test := range testSet {
require := require.New(t)
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
resp, err := testConfig.provider.Class(context.Background(), test.BlockID, test.ClassHash)
require.NoError(err)

switch class := resp.(type) {
case *DeprecatedContractClass:
diff, err := spy.Compare(class, false)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")

if !strings.HasPrefix(class.Program, test.ExpectedProgram) {
t.Fatal("code should exist")
}
case *ContractClass:
diff, err := spy.Compare(class, false)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")
require.Equal(class.SierraProgram[len(class.SierraProgram)-1].String(), test.ExpectedProgram)
require.Equal(class.EntryPointsByType.Constructor[0], test.ExpectedEntryPointConstructor)
default:
Expand Down Expand Up @@ -351,14 +328,8 @@ func TestStorageAt(t *testing.T) {

for _, test := range testSet {
require := require.New(t)
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
value, err := testConfig.provider.StorageAt(context.Background(), test.ContractHash, test.StorageKey, test.Block)
require.NoError(err)

diff, err := spy.Compare(value, false)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")
require.EqualValues(test.ExpectedValue, value)
}
}
Expand Down Expand Up @@ -416,16 +387,9 @@ func TestNonce(t *testing.T) {

for _, test := range testSet {
require := require.New(t)
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
nonce, err := testConfig.provider.Nonce(context.Background(), test.Block, test.ContractAddress)
require.NoError(err)
require.NotNil(nonce, "should return a nonce")

diff, err := spy.Compare(nonce, false)
require.NoError(err, "expecting to match")
require.Equal(diff, "FullMatch", "structure expecting to be FullMatch")

require.Equal(test.ExpectedNonce, nonce)
}
}
Expand Down Expand Up @@ -462,14 +426,11 @@ func TestEstimateMessageFee(t *testing.T) {
}[testEnv]

for _, test := range testSet {
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
value, err := testConfig.provider.EstimateMessageFee(context.Background(), test.MsgFromL1, test.BlockID)
if err != nil {
t.Fatal(err)
}
require.Equal(t, *value, test.ExpectedFeeEst)

}
}

Expand Down Expand Up @@ -571,8 +532,6 @@ func TestEstimateFee(t *testing.T) {
}[testEnv]

for _, test := range testSet {
spy := NewSpy(testConfig.provider.c)
testConfig.provider.c = spy
resp, err := testConfig.provider.EstimateFee(context.Background(), test.txs, test.simFlags, test.blockID)
require.Equal(t, test.expectedError, err)
require.Equal(t, test.expectedResp, resp)
Expand Down

0 comments on commit f9fc2bd

Please sign in to comment.