Skip to content

Commit

Permalink
Enable obscuroscan test (#1566)
Browse files Browse the repository at this point in the history
* Enable obscuroscan test

* lint

* pr comments
  • Loading branch information
otherview authored Oct 2, 2023
1 parent 42b98cf commit 701bd07
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions integration/obscuroscan/obscuroscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand All @@ -65,12 +64,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(genesis.TestnetPrefundedPK, integration.ObscuroChainID, testlog.Logger()),
5,
)

// Issue tests
statusCode, body, err := fasthttp.Get(nil, fmt.Sprintf("%s/count/contracts/", serverAddress))
assert.NoError(t, err)
Expand All @@ -80,7 +86,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)
Expand All @@ -99,7 +105,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)

Expand All @@ -114,8 +120,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)
Expand Down Expand Up @@ -171,15 +177,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)
Expand All @@ -206,15 +203,15 @@ 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(),
Wallets: wallets,
StartPort: startPort,
WithPrefunding: true,
}

obscuroNetwork := network.NewNetworkOfSocketNodes(wallets)
Expand Down

0 comments on commit 701bd07

Please sign in to comment.