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/api/service/syncing/syncing_test.go

51 lines
1.7 KiB

package syncing
import (
"testing"
"github.com/harmony-one/harmony/api/service/syncing/downloader"
"github.com/stretchr/testify/assert"
)
// Simple test for IncorrectResponse
func TestCreateTestSyncPeerConfig(t *testing.T) {
client := &downloader.Client{}
blockHashes := [][]byte{{}}
syncPeerConfig := CreateTestSyncPeerConfig(client, blockHashes)
assert.Equal(t, client, syncPeerConfig.GetClient(), "error")
}
// Simple test for IncorrectResponse
func TestCompareSyncPeerConfigByblockHashes(t *testing.T) {
client := &downloader.Client{}
blockHashes1 := [][]byte{{1, 2, 3}}
syncPeerConfig1 := CreateTestSyncPeerConfig(client, blockHashes1)
blockHashes2 := [][]byte{{1, 2, 4}}
syncPeerConfig2 := CreateTestSyncPeerConfig(client, blockHashes2)
// syncPeerConfig1 is less than syncPeerConfig2
assert.Equal(t, CompareSyncPeerConfigByblockHashes(syncPeerConfig1, syncPeerConfig2), -1, "syncPeerConfig1 is less than syncPeerConfig2")
// syncPeerConfig1 is greater than syncPeerConfig2
blockHashes1[0][2] = 5
assert.Equal(t, CompareSyncPeerConfigByblockHashes(syncPeerConfig1, syncPeerConfig2), 1, "syncPeerConfig1 is greater than syncPeerConfig2")
// syncPeerConfig1 is equal to syncPeerConfig2
blockHashes1[0][2] = 4
assert.Equal(t, CompareSyncPeerConfigByblockHashes(syncPeerConfig1, syncPeerConfig2), 0, "syncPeerConfig1 is equal to syncPeerConfig2")
// syncPeerConfig1 is less than syncPeerConfig2
assert.Equal(t,
CompareSyncPeerConfigByblockHashes(
syncPeerConfig1, syncPeerConfig2,
),
0, "syncPeerConfig1 is less than syncPeerConfig2")
}
func TestCreateStateSync(t *testing.T) {
stateSync := CreateStateSync("127.0.0.1", "8000", [20]byte{})
if stateSync == nil {
t.Error("Unable to create stateSync")
}
}