Skip to content
Merged
Show file tree
Hide file tree
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
54 changes: 0 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,57 +53,3 @@ jobs:
run: |
make test

## NOTE: currently disabled running reorgme tests on gh-actions
## but certainly recommend to run them locally!
#
# test-with-reorgme:
# env:
# GOPATH: ${{ github.workspace }}
# GO111MODULE: on

# defaults:
# run:
# working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}

# strategy:
# matrix:
# go-version: [1.16.x]
# os: [ubuntu-latest]

# runs-on: ${{ matrix.os }}

# steps:
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: ${{ matrix.go-version }}
# - name: Checkout code
# uses: actions/checkout@v2
# with:
# path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
# - name: Install node
# uses: actions/setup-node@v1
# with:
# node-version: '14.x'
# - uses: actions/cache@master
# id: yarn-cache
# with:
# path: |
# ./tools/testchain/node_modules
# key: ${{ runner.os }}-install-reorgme-${{ hashFiles('./tools/testchain/package.json', './tools/testchain/yarn.lock') }}
# - name: Yarn install
# run: cd ./tools/testchain && yarn install --network-concurrency 1
# - name: Start testchain
# run: make start-testchain-detached
# - name: testchain logs
# run: make testchain-logs &> /tmp/chain.log &
# - name: Test
# timeout-minutes: 20
# run: |
# make test-with-reorgme
# - name: 'Upload chain logs'
# uses: actions/upload-artifact@v2
# with:
# name: testchain-logs
# path: /tmp/chain.log
# retention-days: 5
23 changes: 0 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ install:
# Run baseline tests
test: check-testchain-running go-test

# Run tests with reorgme
test-with-reorgme: check-reorgme-running
REORGME=true $(MAKE) go-test

# Go test short-hand, and skip testing go-ethereum
go-test: test-clean
GOGC=off go test $(TEST_FLAGS) $(MOD_VENDOR) -race -run=$(TEST) `go list ./... | grep -v go-ethereum`
Expand All @@ -74,7 +70,6 @@ test-clean:
.PHONY: tools
tools:
cd ./ethtest/testchain && pnpm install
cd ./ethtest/reorgme && pnpm install


#
Expand Down Expand Up @@ -106,24 +101,6 @@ check-testchain-running:
|| { echo "*****"; echo "Oops! testchain is not running. Please run 'make start-testchain' in another terminal."; echo "*****"; exit 1; }


#
# Reorgme
#
start-reorgme:
cd ./ethtest/reorgme && pnpm start:server

start-reorgme-detached:
cd ./ethtest/reorgme && pnpm start:server:detached

stop-reorgme-detached:
cd ./ethtest/reorgme && pnpm start:stop:detached

reorgme-logs:
cd ./ethtest/reorgme && pnpm chain:logs

check-reorgme-running:
cd ./ethtest/reorgme && bash isRunning.sh


#
# Dep management
Expand Down
150 changes: 0 additions & 150 deletions ethmonitor/ethmonitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import (
"fmt"
"math/big"
"net/http"
"os"
"os/exec"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -145,153 +142,6 @@ func TestMonitorBasic(t *testing.T) {
assert.Equal(t, 1, monitor.NumSubscribers())
}

func GetIp(index uint) string {
output, err := exec.Command("yarn", "--silent", "--cwd", "../tools/reorgme", "chain:ip", "0").CombinedOutput()

if err != nil {
os.Stderr.WriteString(err.Error())
}

return strings.Replace(string(output), "\n", "", 1)
}

func WaitBlock(ctx context.Context, provider *ethrpc.Provider) error {
var lastBlock = uint64(0)

fmt.Println("Waiting a block")

for {
block, err := provider.BlockNumber(ctx)
if err != nil {
return err
}

if lastBlock == 0 {
lastBlock = block
}

if block != lastBlock {
return nil
}
}
}

func Fork(index uint) string {
fmt.Println("Forking...")
output, err := exec.Command("yarn", "--silent", "--cwd", "../tools/reorgme", "chain:fork").CombinedOutput()

if err != nil {
os.Stderr.WriteString(err.Error())
}

fmt.Println("Forked!")

return string(output)
}

func Join(index uint) string {
fmt.Println("Joining...")
output, err := exec.Command("yarn", "--silent", "--cwd", "../tools/reorgme", "chain:join").CombinedOutput()

if err != nil {
os.Stderr.WriteString(err.Error())
}

fmt.Println("Joined!")

return string(output)
}

func TestMonitorWithReorgme(t *testing.T) {
if strings.ToLower(os.Getenv("REORGME")) != "true" {
t.Logf("REORGME is not enabled, skipping this test case.")
return
}

ip := GetIp(0)

provider, err := ethrpc.NewProvider("http://" + ip + ":8545/")
assert.NoError(t, err)

monitorOptions := ethmonitor.DefaultOptions
monitorOptions.PollingInterval = 5 * time.Millisecond

monitor, err := ethmonitor.NewMonitor(provider, monitorOptions)
assert.NoError(t, err)

go func(t *testing.T) {
err := monitor.Run(context.Background())
if err != nil {
panic(err)
}
}(t)
defer monitor.Stop()

sub := monitor.Subscribe("TestMonitorWithReorgme")
defer sub.Unsubscribe()

events := make([]*ethmonitor.Block, 0)

go func() {
for {
select {
case blocks := <-sub.Blocks():
_ = blocks
for _, b := range blocks {
events = append(events, b)
fmt.Println("event:", b.Event, "block:", b.NumberU64(), b.Hash().Hex(), "parent:", b.ParentHash().Hex(), "# logs:", len(b.Logs))
}
case <-sub.Done():
return
}
}
}()

Fork(0)
events = make([]*ethmonitor.Block, 0)

WaitBlock(context.Background(), provider)
WaitBlock(context.Background(), provider)

time.Sleep(2 * time.Second)

for _, b := range events {
assert.Equal(t, b.Event, ethmonitor.Added)
}

revertedEvents := events
events = make([]*ethmonitor.Block, 0)

Join(0)

// Wait for reorg
WaitBlock(context.Background(), provider)
WaitBlock(context.Background(), provider)

time.Sleep(2 * time.Second)

offset := 0
for _, e := range events {
if e.Block.Hash() == revertedEvents[len(revertedEvents)-1].Hash() {
break
}

offset++
}

for i, b := range revertedEvents {
ri := len(revertedEvents) - 1 - i + offset
rb := events[ri]

// Should revert last blocks
assert.Equal(t, rb.Block.Number(), b.Block.Number())
assert.Equal(t, rb.Block.Hash(), b.Block.Hash())
assert.Equal(t, b.Event, ethmonitor.Removed)
}

monitor.Stop()
}

func TestMonitorFeeHistory(t *testing.T) {
const N = 1

Expand Down
7 changes: 0 additions & 7 deletions ethtest/reorgme.go

This file was deleted.

1 change: 0 additions & 1 deletion ethtest/reorgme/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions ethtest/reorgme/isRunning.sh

This file was deleted.

18 changes: 0 additions & 18 deletions ethtest/reorgme/package.json

This file was deleted.

Loading
Loading