aboutsummaryrefslogtreecommitdiff
path: root/test_p2p_stress
diff options
context:
space:
mode:
Diffstat (limited to 'test_p2p_stress')
-rw-r--r--test_p2p_stress/main.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/test_p2p_stress/main.go b/test_p2p_stress/main.go
index 1051440..6670f03 100644
--- a/test_p2p_stress/main.go
+++ b/test_p2p_stress/main.go
@@ -26,6 +26,7 @@ import "C"
import (
"github.com/Determinant/salticidae-go"
"math/rand"
+ "os"
"fmt"
"sync"
"unsafe"
@@ -70,6 +71,13 @@ func msgAckUnserialize(msg salticidae.Msg) salticidae.UInt256 {
return hash
}
+func checkError(err *salticidae.Error) {
+ if err.GetCode() != 0 {
+ fmt.Printf("error during a sync call: %s\n", salticidae.StrError(err.GetCode()))
+ os.Exit(1)
+ }
+}
+
type TestContext struct {
timer salticidae.TimerEvent
timer_ctx *C.struct_timeout_callback_context_t
@@ -133,8 +141,7 @@ func sendRand(size int, app *AppContext, conn salticidae.MsgNetworkConn) {
salticidae.UInt256(tc.hash).Free()
}
tc.hash = hash
- app.net.AsMsgNetwork().SendMsg(msg, conn)
- msg.Free()
+ app.net.AsMsgNetwork().SendMsgByMove(msg, conn)
}
var apps []AppContext
@@ -165,9 +172,8 @@ func onReceiveRand(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, user
conn := salticidae.MsgNetworkConn(_conn)
net := conn.GetNet()
ack := msgAckSerialize(hash)
- net.SendMsg(ack, conn)
hash.Free()
- ack.Free()
+ net.SendMsgByMove(ack, conn)
}
//export onReceiveAck
@@ -287,8 +293,9 @@ func main() {
for i, _ := range apps {
app_id := i
go func() {
+ err := salticidae.NewError()
a := &apps[app_id]
- a.net.Listen(a.addr)
+ a.net.Listen(a.addr, &err)
for _, addr := range addrs {
if !addr.IsEq(a.addr) {
a.net.AddPeer(addr)