From 6ba38145898870a26e45ddf877104d69e21850c8 Mon Sep 17 00:00:00 2001 From: otherview Date: Fri, 29 Sep 2023 17:34:07 +0100 Subject: [PATCH 1/3] Enable obscuroscan test --- integration/obscuroscan/obscuroscan_test.go | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/integration/obscuroscan/obscuroscan_test.go b/integration/obscuroscan/obscuroscan_test.go index d17d735539..2ca35bf3fd 100644 --- a/integration/obscuroscan/obscuroscan_test.go +++ b/integration/obscuroscan/obscuroscan_test.go @@ -47,7 +47,7 @@ const ( ) func TestObscuroscan(t *testing.T) { - t.Skip("Commented it out until more testing is driven from this test") + //t.Skip("Commented it out until more testing is driven from this test") startPort := integration.StartPortObscuroscanUnitTest createObscuroNetwork(t, startPort) @@ -65,12 +65,19 @@ func TestObscuroscan(t *testing.T) { require.NoError(t, err) // wait for the msg bus contract to be deployed - time.Sleep(10 * time.Second) + time.Sleep(30 * time.Second) // make sure the server is ready to receive requests err = waitServerIsReady(serverAddress) require.NoError(t, err) + issueTransactions( + t, + fmt.Sprintf("ws://127.0.0.1:%d", startPort+integration.DefaultHostRPCWSOffset), + wallet.NewInMemoryWalletFromConfig("8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b", integration.ObscuroChainID, testlog.Logger()), + 5, + ) + // Issue tests statusCode, body, err := fasthttp.Get(nil, fmt.Sprintf("%s/count/contracts/", serverAddress)) assert.NoError(t, err) @@ -80,7 +87,7 @@ func TestObscuroscan(t *testing.T) { statusCode, body, err = fasthttp.Get(nil, fmt.Sprintf("%s/count/transactions/", serverAddress)) assert.NoError(t, err) assert.Equal(t, 200, statusCode) - assert.Equal(t, "{\"count\":1}", string(body)) + assert.Equal(t, "{\"count\":6}", string(body)) statusCode, body, err = fasthttp.Get(nil, fmt.Sprintf("%s/items/batch/latest/", serverAddress)) assert.NoError(t, err) @@ -99,7 +106,7 @@ func TestObscuroscan(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 200, statusCode) - statusCode, _, err = fasthttp.Get(nil, fmt.Sprintf("%s/items/batchHeader/%s", serverAddress, batchHead.Hash().String())) + statusCode, _, err = fasthttp.Get(nil, fmt.Sprintf("%s/items/batch/%s", serverAddress, batchHead.Hash().String())) assert.NoError(t, err) assert.Equal(t, 200, statusCode) @@ -114,8 +121,8 @@ func TestObscuroscan(t *testing.T) { publicTxsObj := publicTxsRes{} err = json.Unmarshal(body, &publicTxsObj) assert.NoError(t, err) - assert.Equal(t, 1, len(publicTxsObj.Result.TransactionsData)) - assert.Equal(t, uint64(1), publicTxsObj.Result.Total) + assert.Equal(t, 5, len(publicTxsObj.Result.TransactionsData)) + assert.Equal(t, uint64(5), publicTxsObj.Result.Total) statusCode, body, err = fasthttp.Get(nil, fmt.Sprintf("%s/items/batches/?offset=0&size=10", serverAddress)) assert.NoError(t, err) @@ -171,15 +178,6 @@ func TestObscuroscan(t *testing.T) { assert.NoError(t, err) assert.NotEqual(t, configFetchObj.Item.SequencerID, gethcommon.Address{}) - issueTransactions( - t, - fmt.Sprintf("ws://127.0.0.1:%d", startPort+integration.DefaultHostRPCWSOffset), - wallet.NewInMemoryWalletFromConfig("8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b", integration.ObscuroChainID, testlog.Logger()), - 100, - ) - - fmt.Println("Running for 1 hour...") - time.Sleep(time.Hour) // Gracefully shutdown err = obsScanContainer.Stop() assert.NoError(t, err) @@ -215,6 +213,7 @@ func createObscuroNetwork(t *testing.T, startPort int) { ERC20ContractLib: ethereummock.NewERC20ContractLibMock(), Wallets: wallets, StartPort: startPort, + WithPrefunding: true, } obscuroNetwork := network.NewNetworkOfSocketNodes(wallets) From 3fc9d5254ea17df6534774af67169fc141342f26 Mon Sep 17 00:00:00 2001 From: otherview Date: Fri, 29 Sep 2023 18:05:04 +0100 Subject: [PATCH 2/3] lint --- integration/obscuroscan/obscuroscan_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/integration/obscuroscan/obscuroscan_test.go b/integration/obscuroscan/obscuroscan_test.go index 2ca35bf3fd..e2972c93af 100644 --- a/integration/obscuroscan/obscuroscan_test.go +++ b/integration/obscuroscan/obscuroscan_test.go @@ -47,7 +47,6 @@ const ( ) func TestObscuroscan(t *testing.T) { - //t.Skip("Commented it out until more testing is driven from this test") startPort := integration.StartPortObscuroscanUnitTest createObscuroNetwork(t, startPort) @@ -204,10 +203,9 @@ func waitServerIsReady(serverAddr string) error { // Creates a single-node Obscuro network for testing. func createObscuroNetwork(t *testing.T, startPort int) { // Create the Obscuro network. - numberOfNodes := 1 - wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(1, 1, integration.EthereumChainID, integration.ObscuroChainID) simParams := params.SimParams{ - NumberOfNodes: numberOfNodes, + NumberOfNodes: 1, AvgBlockDuration: 1 * time.Second, MgmtContractLib: ethereummock.NewMgmtContractLibMock(), ERC20ContractLib: ethereummock.NewERC20ContractLibMock(), From 4b0b680926dc3f29cce01a4289e19d8d576b5ef5 Mon Sep 17 00:00:00 2001 From: otherview Date: Mon, 2 Oct 2023 11:32:15 +0100 Subject: [PATCH 3/3] pr comments --- integration/obscuroscan/obscuroscan_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/obscuroscan/obscuroscan_test.go b/integration/obscuroscan/obscuroscan_test.go index e2972c93af..e89acab30a 100644 --- a/integration/obscuroscan/obscuroscan_test.go +++ b/integration/obscuroscan/obscuroscan_test.go @@ -13,11 +13,11 @@ import ( gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/obscuronet/go-obscuro/go/common/viewingkey" + "github.com/obscuronet/go-obscuro/go/enclave/genesis" "github.com/obscuronet/go-obscuro/go/obsclient" "github.com/obscuronet/go-obscuro/go/rpc" "github.com/obscuronet/go-obscuro/go/wallet" "github.com/obscuronet/go-obscuro/integration/datagenerator" - "github.com/obscuronet/go-obscuro/tools/obscuroscan_v2/backend/config" "github.com/obscuronet/go-obscuro/tools/obscuroscan_v2/backend/container" "github.com/stretchr/testify/require" @@ -73,7 +73,7 @@ func TestObscuroscan(t *testing.T) { issueTransactions( t, fmt.Sprintf("ws://127.0.0.1:%d", startPort+integration.DefaultHostRPCWSOffset), - wallet.NewInMemoryWalletFromConfig("8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b", integration.ObscuroChainID, testlog.Logger()), + wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.ObscuroChainID, testlog.Logger()), 5, )