The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/internal/utils/crosslinks/crosslinks_test.go

36 lines
925 B

Epoch syncing - syncing only epoch blocks. (#4070) * Epoch syncing - syncing only epoch blocks. * Fix go test, added command to run. * Block signature validation. * Support getting block by height. * Fix to compile. * Http method. * Generate fix. * Install protoc-gen-go-grpc. * Fix sync, additional timeouts, fix epoch. * Chain behaviour options, optional state validation on blockchain initialization. * Added limit to avoid abuse, small fixes. * Fix duplicate code. * Fix isInSyn. * Fix method call. * Removed additional block sending. * Fix in sync. * Code clean up. * Fix beacon chain func. * Return back Beaconchain. * Fix sending only epoch blocks. * Fix failed startup with validator. * Increase recv message size. * Remove peer. * Add logs. * Add logs. * Fix msgf call. * Epoch syncing - syncing only epoch blocks. * Block signature validation. * Fix sync, additional timeouts, fix epoch. * Chain behaviour options, optional state validation on blockchain initialization. * Support getting block by height. * Http method. * Fix duplicate code. * Fix isInSyn. * Added limit to avoid abuse, small fixes. * Fix method call. * Removed additional block sending. * Fix in sync. * Small fix. * Code clean up. * Fix beacon chain func. * Return back Beaconchain. * Fix sending only epoch blocks. * Fix failed startup with validator. * Increase recv message size. * Remove peer. * Add logs. * Fix msgf call. * Sending crosslinks from beacon to non-beacon chains. * Receiving crosslinks. * Broadcast. * Fix comment. * Crosslink signal. * Crosslink hardbeat signal receiving. * Sending crosslinks from beacon to non-beacon chains. * Sending crosslinks from beacon to non-beacon chains. * Broadcast. * Fix comment. * Crosslink signal. * Crosslink signal. * Add comment to run tests. * Fix comments. * Fix comments. * Fix review comments. * Updated with last crosslink heart beat signal. * Merged crosslink signal. * Clean up code. * Add logs for cl debug. * Stop iterate on receiving result. * Add logs. * Fix in sync check. * Fix reconnect problems. * Fix tests and reduce dependency. * Updated with main. * Fix review comments. * Changed to compare epochs. * Fix crosslinks usage. * Fix initialization. * Epoch chain implementation. * Legacy sync by default. * Revert "Legacy sync by default." This reverts commit 5fa6ce002a16699cc3ca75bdd40b068dbe6cefb6. * Epoch sync for downloader. * Build docker image while tests. * Fix paths. * Updated travis. * Review improvements. Co-authored-by: Konstantin <k.potapov@softpro.com>
2 years ago
package crosslinks_test
import (
"testing"
"unsafe"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/utils/crosslinks"
"github.com/stretchr/testify/require"
)
func TestCrosslink(t *testing.T) {
t.Parallel()
s := crosslinks.New()
require.EqualValues(t, 0, s.LatestSentCrosslinkBlockNumber())
s.SetLatestSentCrosslinkBlockNumber(5)
require.EqualValues(t, 5, s.LatestSentCrosslinkBlockNumber())
}
func TestSignal(t *testing.T) {
t.Parallel()
s := crosslinks.New()
require.Nil(t, s.LastKnownCrosslinkHeartbeatSignal())
signal := &types.CrosslinkHeartbeat{LatestContinuousBlockNum: 10}
s.SetLastKnownCrosslinkHeartbeatSignal(signal)
// They should have same value.
require.Equal(t, signal, s.LastKnownCrosslinkHeartbeatSignal())
// They should have even same pointer.
require.Equal(t, unsafe.Pointer(signal), unsafe.Pointer(s.LastKnownCrosslinkHeartbeatSignal()))
}