diff --git a/rpc/contract_test.go b/rpc/contract_test.go index 828ec500..5d6fef65 100644 --- a/rpc/contract_test.go +++ b/rpc/contract_test.go @@ -41,21 +41,27 @@ func TestClassAt(t *testing.T) { for _, test := range testSet { spy := NewSpy(testConfig.provider.c) testConfig.provider.c = spy - class, err := testConfig.provider.ClassAt(context.Background(), WithBlockTag("latest"), test.ContractAddress) + resp, err := testConfig.provider.ClassAt(context.Background(), WithBlockTag("latest"), test.ContractAddress) if err != nil { t.Fatal(err) } - diff, err := spy.Compare(class, false) - if err != nil { - t.Fatal("expecting to match", err) - } - if diff != "FullMatch" { - spy.Compare(class, true) - t.Fatal("structure expecting to be FullMatch, instead", diff) - } - if class == nil || class.Program == "" { - t.Fatal("code should exist") + switch class := resp.(type) { + case DepcreatedContractClass: + diff, err := spy.Compare(class, false) + if err != nil { + t.Fatal("expecting to match", err) + } + if diff != "FullMatch" { + spy.Compare(class, true) + t.Fatal("structure expecting to be FullMatch, instead", diff) + } + if class.Program == "" { + t.Fatal("code should exist") + } + case ContractClass: + panic("Not covered") } + } } @@ -143,21 +149,28 @@ func TestClass(t *testing.T) { for _, test := range testSet { spy := NewSpy(testConfig.provider.c) testConfig.provider.c = spy - class, err := testConfig.provider.Class(context.Background(), WithBlockTag("latest"), test.ClassHash) + resp, err := testConfig.provider.Class(context.Background(), WithBlockTag("latest"), test.ClassHash) if err != nil { t.Fatal(err) } - diff, err := spy.Compare(class, false) - if err != nil { - t.Fatal("expecting to match", err) - } - if diff != "FullMatch" { - spy.Compare(class, true) - t.Fatal("structure expecting to be FullMatch, instead", diff) - } - if class == nil || !strings.HasPrefix(class.Program, test.ExpectedProgram) { - t.Fatal("code should exist") + switch class := resp.(type) { + case DepcreatedContractClass: + + diff, err := spy.Compare(class, false) + if err != nil { + t.Fatal("expecting to match", err) + } + if diff != "FullMatch" { + spy.Compare(class, true) + t.Fatal("structure expecting to be FullMatch, instead", diff) + } + + if !strings.HasPrefix(class.Program, test.ExpectedProgram) { + t.Fatal("code should exist") + } + case ContractClass: + panic("Not covered") } } }