Skip to content

Commit

Permalink
Remove useless tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cabrador committed Dec 2, 2024
1 parent 56a3e7c commit 7e8b12c
Showing 1 changed file with 0 additions and 108 deletions.
108 changes: 0 additions & 108 deletions utils/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,111 +104,3 @@ func TestSendRPCRequest_InvalidChainID(t *testing.T) {
}

}

// TestSendRPCRequest_InvalidReqMethod tests whether SendRpcRequest does return an error for an invalid method inside request
func TestSendRPCRequest_InvalidReqMethod(t *testing.T) {
req := JsonRPCRequest{
Method: "ftm_invalid",
Params: []interface{}{"latest", false},
ID: 1,
JSONRPC: "2.0",
}

for _, id := range maps.Keys(RealChainIDs) {
t.Run(fmt.Sprintf("ChainID %v", id), func(t *testing.T) {
res, err := SendRpcRequest(req, id)
if errors.Is(err, RPCUnsupported) {
t.Skip("RPC is not supported")
}
if err != nil {
t.Fatalf("SendRpcRequest returned err; %v", err)
}

if res == nil {
t.Fatal("response was nil")
}

e, ok := res["error"]
if !ok {
t.Fatal("response did not have an error")
}

_, ok = e.(map[string]interface{})
if !ok {
t.Fatal("error cannot be retyped to map")
}
})
}
}

// TestSendRPCRequest_InvalidReqMethod tests whether SendRpcRequest does return an error for an invalid block number inside request
func TestSendRPCRequest_InvalidBlockNumber(t *testing.T) {
req := JsonRPCRequest{
Method: "ftm_getBlockByNumber",
Params: []interface{}{"0xinvalid", false},
ID: 1,
JSONRPC: "2.0",
}

for _, id := range maps.Keys(RealChainIDs) {
t.Run(fmt.Sprintf("ChainID %v", id), func(t *testing.T) {
res, err := SendRpcRequest(req, id)
if errors.Is(err, RPCUnsupported) {
t.Skipf("RPC is not supported")
}
if err != nil {
t.Fatalf("SendRpcRequest returned err; %v", err)
}

if res == nil {
t.Fatal("response was nil")
}

e, ok := res["error"]
if !ok {
t.Fatal("response did not have an error")
}

_, ok = e.(map[string]interface{})
if !ok {
t.Fatal("error cannot be retyped to map")
}
})
}

}

// TestRPCFindEpochNumber_Positive tests whether FindEpochNumber does not return error for a valid block and chainID
func TestRPCFindEpochNumber_Positive(t *testing.T) {
var (
expectedMainnetEpoch uint64 = 5576
testingMainnetBlock uint64 = 4_564_025
)

for _, id := range maps.Keys(RealChainIDs) {
t.Run(fmt.Sprintf("ChainID %v", id), func(t *testing.T) {
var testingBlock, expectedEpoch uint64

if id == MainnetChainID {
testingBlock = testingMainnetBlock
expectedEpoch = expectedMainnetEpoch
} else if id == TestnetChainID {
t.Skip("Opera Testnet ChainID is not supported")
} else if id == EthereumChainID {
t.Skip("EthereumChainID is not supported")
} else {
t.Fatalf("unknown chainID: %v", id)
}

returnedEpoch, err := FindEpochNumber(testingBlock, id)
if err != nil {
t.Fatalf("FindEpochNumber returned err; %v", err)
}

if expectedEpoch != returnedEpoch {
t.Fatalf("block numbers are different; returned: %v, expected: %v", returnedEpoch, expectedEpoch)
}
})
}

}

0 comments on commit 7e8b12c

Please sign in to comment.