aboutsummaryrefslogtreecommitdiffstats
path: root/les/sync_test.go
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2019-08-21 17:29:34 +0800
committerFelföldi Zsolt <zsfelfoldi@gmail.com>2019-08-21 17:29:34 +0800
commit2ed729d38e90154d1f23ebdf5a9f2808212276d8 (patch)
tree04aad0e43f8a0b191809a86a2b665535f1f87a93 /les/sync_test.go
parent4aee0d1994ad286c18aa3a586ae950e96979a7f1 (diff)
downloadgo-tangerine-2ed729d38e90154d1f23ebdf5a9f2808212276d8.tar
go-tangerine-2ed729d38e90154d1f23ebdf5a9f2808212276d8.tar.gz
go-tangerine-2ed729d38e90154d1f23ebdf5a9f2808212276d8.tar.bz2
go-tangerine-2ed729d38e90154d1f23ebdf5a9f2808212276d8.tar.lz
go-tangerine-2ed729d38e90154d1f23ebdf5a9f2808212276d8.tar.xz
go-tangerine-2ed729d38e90154d1f23ebdf5a9f2808212276d8.tar.zst
go-tangerine-2ed729d38e90154d1f23ebdf5a9f2808212276d8.zip
les: handler separation (#19639)
les: handler separation
Diffstat (limited to 'les/sync_test.go')
-rw-r--r--les/sync_test.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/les/sync_test.go b/les/sync_test.go
index 3a75d6856..63833c1ab 100644
--- a/les/sync_test.go
+++ b/les/sync_test.go
@@ -57,7 +57,7 @@ func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {
}
}
// Generate 512+4 blocks (totally 1 CHT sections)
- server, client, tearDown := newClientServerEnv(t, int(config.ChtSize+config.ChtConfirms), protocol, waitIndexers, false)
+ server, client, tearDown := newClientServerEnv(t, int(config.ChtSize+config.ChtConfirms), protocol, waitIndexers, nil, 0, false, false)
defer tearDown()
expected := config.ChtSize + config.ChtConfirms
@@ -74,8 +74,8 @@ func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {
}
if syncMode == 1 {
// Register the assembled checkpoint as hardcoded one.
- client.pm.checkpoint = cp
- client.pm.blockchain.(*light.LightChain).AddTrustedCheckpoint(cp)
+ client.handler.checkpoint = cp
+ client.handler.backend.blockchain.AddTrustedCheckpoint(cp)
} else {
// Register the assembled checkpoint into oracle.
header := server.backend.Blockchain().CurrentHeader()
@@ -83,14 +83,14 @@ func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {
data := append([]byte{0x19, 0x00}, append(registrarAddr.Bytes(), append([]byte{0, 0, 0, 0, 0, 0, 0, 0}, cp.Hash().Bytes()...)...)...)
sig, _ := crypto.Sign(crypto.Keccak256(data), signerKey)
sig[64] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper
- if _, err := server.pm.reg.contract.RegisterCheckpoint(bind.NewKeyedTransactor(signerKey), cp.SectionIndex, cp.Hash().Bytes(), new(big.Int).Sub(header.Number, big.NewInt(1)), header.ParentHash, [][]byte{sig}); err != nil {
+ if _, err := server.handler.server.oracle.contract.RegisterCheckpoint(bind.NewKeyedTransactor(signerKey), cp.SectionIndex, cp.Hash().Bytes(), new(big.Int).Sub(header.Number, big.NewInt(1)), header.ParentHash, [][]byte{sig}); err != nil {
t.Error("register checkpoint failed", err)
}
server.backend.Commit()
// Wait for the checkpoint registration
for {
- _, hash, _, err := server.pm.reg.contract.Contract().GetLatestCheckpoint(nil)
+ _, hash, _, err := server.handler.server.oracle.contract.Contract().GetLatestCheckpoint(nil)
if err != nil || hash == [32]byte{} {
time.Sleep(100 * time.Millisecond)
continue
@@ -102,8 +102,8 @@ func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {
}
done := make(chan error)
- client.pm.reg.syncDoneHook = func() {
- header := client.pm.blockchain.CurrentHeader()
+ client.handler.backend.oracle.syncDoneHook = func() {
+ header := client.handler.backend.blockchain.CurrentHeader()
if header.Number.Uint64() == expected {
done <- nil
} else {
@@ -112,7 +112,7 @@ func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {
}
// Create connected peer pair.
- peer, err1, lPeer, err2 := newTestPeerPair("peer", protocol, server.pm, client.pm)
+ _, err1, _, err2 := newTestPeerPair("peer", protocol, server.handler, client.handler)
select {
case <-time.After(time.Millisecond * 100):
case err := <-err1:
@@ -120,7 +120,6 @@ func testCheckpointSyncing(t *testing.T, protocol int, syncMode int) {
case err := <-err2:
t.Fatalf("peer 2 handshake error: %v", err)
}
- server.rPeer, client.rPeer = peer, lPeer
select {
case err := <-done: