Skip to content

Commit

Permalink
Restructuring rpc tests folder (#379)
Browse files Browse the repository at this point in the history
* organize json test files into folders

* rename folder for tests
  • Loading branch information
cicr99 authored Oct 3, 2023
1 parent d1f60d5 commit a381df5
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rpc/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ func mock_starknet_traceBlockTransactions(result interface{}, method string, arg
var rawBlockTrace struct {
Result []Trace `json:"result"`
}
read, err := os.ReadFile("tests/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json")
read, err := os.ReadFile("tests/trace/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json")
if err != nil {
return err
}
Expand Down Expand Up @@ -718,7 +718,7 @@ func mock_starknet_traceTransaction(result interface{}, method string, args ...i
var rawTrace struct {
Result InvokeTxnTrace `json:"result"`
}
read, err := os.ReadFile("tests/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json")
read, err := os.ReadFile("tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json")
if err != nil {
return err
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions rpc/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestTransactionTrace(t *testing.T) {
var rawjson struct {
Result InvokeTxnTrace `json:"result"`
}
expectedrespRaw, err := os.ReadFile("./tests/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json")
expectedrespRaw, err := os.ReadFile("./tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json")
require.NoError(t, err, "Error ReadFile for TestTraceTransaction")

err = json.Unmarshal(expectedrespRaw, &rawjson)
Expand Down Expand Up @@ -79,13 +79,13 @@ func TestSimulateTransaction(t *testing.T) {
var simulateTxIn SimulateTransactionInput
var expectedResp SimulateTransactionOutput
if testEnv == "mainnet" {
simulateTxnRaw, err := os.ReadFile("./tests/simulateInvokeTx.json")
simulateTxnRaw, err := os.ReadFile("./tests/trace/simulateInvokeTx.json")
require.NoError(t, err, "Error ReadFile simulateInvokeTx")

err = json.Unmarshal(simulateTxnRaw, &simulateTxIn)
require.NoError(t, err, "Error unmarshalling simulateInvokeTx")

expectedrespRaw, err := os.ReadFile("./tests/simulateInvokeTxResp.json")
expectedrespRaw, err := os.ReadFile("./tests/trace/simulateInvokeTxResp.json")
require.NoError(t, err, "Error ReadFile simulateInvokeTxResp")

err = json.Unmarshal(expectedrespRaw, &expectedResp)
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestTraceBlockTransactions(t *testing.T) {
var rawjson struct {
Result []Trace `json:"result"`
}
expectedrespRaw, err := os.ReadFile("./tests/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json")
expectedrespRaw, err := os.ReadFile("./tests/trace/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json")
require.NoError(t, err, "Error ReadFile for TestTraceBlockTransactions")

err = json.Unmarshal(expectedrespRaw, &rawjson)
Expand Down
2 changes: 1 addition & 1 deletion rpc/types_types_block_test.go → rpc/types_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestBlockStatus(t *testing.T) {
}
}

//go:embed tests/block.json
//go:embed tests/block/block.json
var rawBlock []byte

func TestBlock_Unmarshal(t *testing.T) {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions rpc/types_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

const (
validDeprecatedContractCompiledPath = "./tests/0x1efa8f84fd4dff9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json"
validContractCompiledPath = "./tests/0x03a8Bad0A71696fC3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json"
validDeprecatedContractCompiledPath = "./tests/contract/0x1efa8f84fd4dff9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json"
validContractCompiledPath = "./tests/contract/0x03a8Bad0A71696fC3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json"
invalidContractCompiledPath = "./tests/0xFakeContract.json"
)

Expand Down
2 changes: 1 addition & 1 deletion rpc/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestDeclareTransaction(t *testing.T) {

for _, test := range testSet {

declareTxJSON, err := os.ReadFile("./tests/declareTx.json")
declareTxJSON, err := os.ReadFile("./tests/write/declareTx.json")
if err != nil {
t.Fatal("should be able to read file", err)
}
Expand Down

0 comments on commit a381df5

Please sign in to comment.