mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-1223] Delete unused files/packages. * [NOD-1223] Move signal and limits to the os package. * [NOD-1223] Put database and dbaccess into the db package. * [NOD-1223] Fold the logs package into the logger package. * [NOD-1223] Rename domainmessage to appmessage. * [NOD-1223] Rename to/from DomainMessage to AppMessage. * [NOD-1223] Move appmessage to the app packge. * [NOD-1223] Move protocol to the app packge. * [NOD-1223] Move the network package to the infrastructure packge. * [NOD-1223] Rename cmd to executables. * [NOD-1223] Fix go.doc in the logger package.
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package integration
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
)
|
|
|
|
func TestIntegrationBasicSync(t *testing.T) {
|
|
appHarness1, appHarness2, appHarness3, teardown := standardSetup(t)
|
|
defer teardown()
|
|
|
|
// Connect nodes in chain: 1 <--> 2 <--> 3
|
|
// So that node 3 doesn't directly get blocks from node 1
|
|
connect(t, appHarness1, appHarness2)
|
|
connect(t, appHarness2, appHarness3)
|
|
|
|
app2OnBlockAddedChan := make(chan *appmessage.BlockHeader)
|
|
setOnBlockAddedHandler(t, appHarness2, func(header *appmessage.BlockHeader) {
|
|
app2OnBlockAddedChan <- header
|
|
})
|
|
|
|
app3OnBlockAddedChan := make(chan *appmessage.BlockHeader)
|
|
setOnBlockAddedHandler(t, appHarness3, func(header *appmessage.BlockHeader) {
|
|
app3OnBlockAddedChan <- header
|
|
})
|
|
|
|
block := mineNextBlock(t, appHarness1)
|
|
|
|
var header *appmessage.BlockHeader
|
|
select {
|
|
case header = <-app2OnBlockAddedChan:
|
|
case <-time.After(defaultTimeout):
|
|
t.Fatalf("Timeout waiting for block added notification on node directly connected to miner")
|
|
}
|
|
|
|
if !header.BlockHash().IsEqual(block.Hash()) {
|
|
t.Errorf("Expected block with hash '%s', but got '%s'", block.Hash(), header.BlockHash())
|
|
}
|
|
|
|
select {
|
|
case header = <-app3OnBlockAddedChan:
|
|
case <-time.After(defaultTimeout):
|
|
t.Fatalf("Timeout waiting for block added notification on node indirectly connected to miner")
|
|
}
|
|
|
|
if !header.BlockHash().IsEqual(block.Hash()) {
|
|
t.Errorf("Expected block with hash '%s', but got '%s'", block.Hash(), header.BlockHash())
|
|
}
|
|
}
|