예제 #1
0
파일: test_test.go 프로젝트: jaked122/Sia
func TestBuild(t *testing.T) {
	// ms == messageSender
	ms, err := network.NewTCPServer(9988)
	if err != nil {
		t.Fatal(err)
	}

	// mh == messageHandler
	mh0, err := quorum.CreateState(ms, 0)
	if err != nil {
		t.Fatal(err)
	}

	mh1, err := quorum.CreateState(ms, 1)
	if err != nil {
		t.Fatal(err)
	}

	mh0.AddParticipant(mh1.Self(), 1)
	mh1.AddParticipant(mh0.Self(), 0)

	mh0.Start()
	mh1.Start()

	time.Sleep(time.Second)
}
예제 #2
0
파일: main.go 프로젝트: jaked122/Sia
func main() {
	// ms == messageSender
	ms, err := network.NewTCPServer(9988)
	if err != nil {
		println("fail")
	}

	// mh == messageHandler
	mh0, err := quorum.CreateState(ms, 0)
	if err != nil {
		println("fail")
	}

	mh1, err := quorum.CreateState(ms, 1)
	if err != nil {
		println("fail")
	}

	mh0.AddParticipant(mh1.Self(), 1)
	mh1.AddParticipant(mh0.Self(), 0)

	mh0.Start()
	mh1.Start()

	time.Sleep(time.Second)
}
예제 #3
0
파일: server_test.go 프로젝트: Radzell/Sia
func TestNetworkedQuorum(t *testing.T) {
	// create a tcp server and 2 states
	// ms == messageSender
	ms, err := network.NewTCPServer(9980)
	if err != nil {
		println("fail")
	}
	// mh == messageHandler
	_, err = quorum.CreateState(ms)
	if err != nil {
		println("fail")
	}
	_, err = quorum.CreateState(ms)
	if err != nil {
		println("fail")
	}

	// more code here
}
예제 #4
0
파일: server_test.go 프로젝트: Jonbeek/Sia
func TestNetworkedQuorum(t *testing.T) {
	// create a MessageRouter and 4 participants
	rpcs, err := network.NewRPCServer(9988)
	if err != nil {
		println("message sender creation failed")
	}

	s0, err := quorum.CreateState(rpcs)
	if err != nil {
		println("s0 creation failed")
	}
	s1, err := quorum.CreateState(rpcs)
	if err != nil {
		println("s1 creation failed")
	}
	s2, err := quorum.CreateState(rpcs)
	if err != nil {
		println("s2 creation failed")
	}
	s3, err := quorum.CreateState(rpcs)
	if err != nil {
		println("s3 creation failed")
	}

	s0.JoinSia()
	s1.JoinSia()
	s2.JoinSia()
	s3.JoinSia()

	// Basically checking for errors up to this point
	if testing.Short() {
		t.Skip()
	}

	time.Sleep(3 * common.StepDuration * time.Duration(common.QuorumSize))

	// if no seg faults, no errors
	// there needs to be a s0.ParticipantStatus() call returning a function with public information about the participant
	// there needs to be a s0.QuorumStatus() call returning public information about the quorum
	// 		all participants in a public quorum should return the same information
}
예제 #5
0
파일: server.go 프로젝트: Jonbeek/Sia
func establishQuorum() {
	var port int
	print("Port number: ")
	fmt.Scanf("%d", &port)
	networkServer, err := network.NewRPCServer(port)
	if err != nil {
		println(err)
		return
	}
	s, err := quorum.CreateState(networkServer)
	s.JoinSia()
	select {}
}
예제 #6
0
파일: server.go 프로젝트: Radzell/Sia
func establishQuorum() {
	networkServer, err := network.NewTCPServer(9988)
	if err != nil {
		println(err)
		return
	}
	participant, err := quorum.CreateState(networkServer)
	if err != nil {
		println(err)
		return
	}
	participant.JoinSia()

	select {}
}