|
|
@ -1,12 +1,11 @@ |
|
|
|
package downloader |
|
|
|
package downloader |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/harmony-one/harmony/blockchain" |
|
|
|
|
|
|
|
"github.com/harmony-one/harmony/crypto/pki" |
|
|
|
"github.com/harmony-one/harmony/crypto/pki" |
|
|
|
"github.com/harmony-one/harmony/node" |
|
|
|
client "github.com/harmony-one/harmony/syncing/downloader/client" |
|
|
|
|
|
|
|
server "github.com/harmony-one/harmony/syncing/downloader/server" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
@ -22,19 +21,20 @@ var ( |
|
|
|
TestAddressTwo = pki.GetAddressFromInt(PriIntTwo) |
|
|
|
TestAddressTwo = pki.GetAddressFromInt(PriIntTwo) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func setupServer() *Server { |
|
|
|
func TestGetBlockHashes(t *testing.T) { |
|
|
|
bc := blockchain.CreateBlockchainWithMoreBlocks([][20]byte{TestAddressOne, TestAddressTwo}, 0) |
|
|
|
s := server.NewServer(nil) |
|
|
|
node := &node.Node{} |
|
|
|
grcpServer, err := s.Start(serverIP, serverPort) |
|
|
|
node.SetBlockchain(bc) |
|
|
|
if err != nil { |
|
|
|
server := NewServer(node) |
|
|
|
t.Error(err) |
|
|
|
fmt.Println("minh ", len(bc.Blocks)) |
|
|
|
|
|
|
|
return server |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
defer grcpServer.Stop() |
|
|
|
|
|
|
|
|
|
|
|
func TestGetBlockHashes(t *testing.T) { |
|
|
|
client := client.ClientSetup(serverIP, serverPort) |
|
|
|
server := setupServer() |
|
|
|
payload := client.GetHeaders() |
|
|
|
server.Start(serverIP) |
|
|
|
if payload[2] != 2 { |
|
|
|
|
|
|
|
t.Error("minh") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// client := ClientSetUp(serverIP, serverPort)
|
|
|
|
defer client.Close() |
|
|
|
// client.GetHeaders()
|
|
|
|
client.GetHeaders() |
|
|
|
} |
|
|
|
} |
|
|
|