From a381df57dea5b4acc529acfd44a1f554b2d51dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carmen=20Irene=20Cabrera=20Rodr=C3=ADguez?= <49727740+cicr99@users.noreply.github.com> Date: Tue, 3 Oct 2023 09:45:39 -0400 Subject: [PATCH] Restructuring rpc tests folder (#379) * organize json test files into folders * rename folder for tests --- rpc/mock_test.go | 4 ++-- rpc/tests/{ => block}/block.json | 0 ...C3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json | 0 ...9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json | 0 ...ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json | 0 ...f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json | 0 rpc/tests/{ => trace}/simulateInvokeTx.json | 0 rpc/tests/{ => trace}/simulateInvokeTxResp.json | 0 rpc/tests/{ => write}/declareTx.json | 0 rpc/trace_test.go | 8 ++++---- rpc/{types_types_block_test.go => types_block_test.go} | 2 +- ...e_block_transactions.go => types_block_transaction.go} | 0 rpc/types_contract_test.go | 4 ++-- rpc/write_test.go | 2 +- 14 files changed, 10 insertions(+), 10 deletions(-) rename rpc/tests/{ => block}/block.json (100%) rename rpc/tests/{ => contract}/0x03a8Bad0A71696fC3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json (100%) rename rpc/tests/{ => contract}/0x1efa8f84fd4dff9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json (100%) rename rpc/tests/{ => trace}/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json (100%) rename rpc/tests/{ => trace}/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json (100%) rename rpc/tests/{ => trace}/simulateInvokeTx.json (100%) rename rpc/tests/{ => trace}/simulateInvokeTxResp.json (100%) rename rpc/tests/{ => write}/declareTx.json (100%) rename rpc/{types_types_block_test.go => types_block_test.go} (98%) rename rpc/{type_block_transactions.go => types_block_transaction.go} (100%) diff --git a/rpc/mock_test.go b/rpc/mock_test.go index 33aecd07..f96492b5 100644 --- a/rpc/mock_test.go +++ b/rpc/mock_test.go @@ -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 } @@ -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 } diff --git a/rpc/tests/block.json b/rpc/tests/block/block.json similarity index 100% rename from rpc/tests/block.json rename to rpc/tests/block/block.json diff --git a/rpc/tests/0x03a8Bad0A71696fC3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json b/rpc/tests/contract/0x03a8Bad0A71696fC3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json similarity index 100% rename from rpc/tests/0x03a8Bad0A71696fC3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json rename to rpc/tests/contract/0x03a8Bad0A71696fC3eB663D0513Dc165Bb42cD4b662e633e3F87a49627CF3AEF.json diff --git a/rpc/tests/0x1efa8f84fd4dff9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json b/rpc/tests/contract/0x1efa8f84fd4dff9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json similarity index 100% rename from rpc/tests/0x1efa8f84fd4dff9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json rename to rpc/tests/contract/0x1efa8f84fd4dff9e2902ec88717cf0dafc8c188f80c3450615944a469428f7f.json diff --git a/rpc/tests/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json b/rpc/tests/trace/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json similarity index 100% rename from rpc/tests/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json rename to rpc/tests/trace/0x3ddc3a8aaac071ecdc5d8d0cfbb1dc4fc6a88272bc6c67523c9baaee52a5ea2.json diff --git a/rpc/tests/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json b/rpc/tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json similarity index 100% rename from rpc/tests/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json rename to rpc/tests/trace/0xff66e14fc6a96f3289203690f5f876cb4b608868e8549b5f6a90a21d4d6329.json diff --git a/rpc/tests/simulateInvokeTx.json b/rpc/tests/trace/simulateInvokeTx.json similarity index 100% rename from rpc/tests/simulateInvokeTx.json rename to rpc/tests/trace/simulateInvokeTx.json diff --git a/rpc/tests/simulateInvokeTxResp.json b/rpc/tests/trace/simulateInvokeTxResp.json similarity index 100% rename from rpc/tests/simulateInvokeTxResp.json rename to rpc/tests/trace/simulateInvokeTxResp.json diff --git a/rpc/tests/declareTx.json b/rpc/tests/write/declareTx.json similarity index 100% rename from rpc/tests/declareTx.json rename to rpc/tests/write/declareTx.json diff --git a/rpc/trace_test.go b/rpc/trace_test.go index ae404abd..f75f23cc 100644 --- a/rpc/trace_test.go +++ b/rpc/trace_test.go @@ -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) @@ -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) @@ -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) diff --git a/rpc/types_types_block_test.go b/rpc/types_block_test.go similarity index 98% rename from rpc/types_types_block_test.go rename to rpc/types_block_test.go index f9f9dbd9..b9a0878c 100644 --- a/rpc/types_types_block_test.go +++ b/rpc/types_block_test.go @@ -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) { diff --git a/rpc/type_block_transactions.go b/rpc/types_block_transaction.go similarity index 100% rename from rpc/type_block_transactions.go rename to rpc/types_block_transaction.go diff --git a/rpc/types_contract_test.go b/rpc/types_contract_test.go index 2715ef27..5105e00d 100644 --- a/rpc/types_contract_test.go +++ b/rpc/types_contract_test.go @@ -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" ) diff --git a/rpc/write_test.go b/rpc/write_test.go index 80bba327..658b0e4c 100644 --- a/rpc/write_test.go +++ b/rpc/write_test.go @@ -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) }