Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable obscuroscan test #1566

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading