func TestDemandFetch(t *testing.T) { comm1, _ := myfs.NewCommunicator("one", myfs.ReadReplicaInfo("input/comm_repl_input")) comm2, _ := myfs.NewCommunicator("two", myfs.ReadReplicaInfo("input/comm_repl_input")) defer comm1.Close() defer comm2.Close() go comm2.ChunkRequestListener(func(hash []byte) []byte { return []byte("omg") }) resp, _ := comm1.RequestChunk("7", []byte("qwer")) assertWithMsg(t, string(resp) == "omg", "Expected chunk should be sent in response") }
func TestMetaBroadcast(t *testing.T) { comm1, _ := myfs.NewCommunicator("one", myfs.ReadReplicaInfo("input/comm_repl_input")) comm2, _ := myfs.NewCommunicator("two", myfs.ReadReplicaInfo("input/comm_repl_input")) defer comm1.Close() defer comm2.Close() go comm2.MetaBroadcastListener(func(payload []byte) { //assertWithMsg(t, false, string(payload)) //assertWithMsg(t, string(payload) == "metainfo", "Payload should match what we broadcast") }) blah := []byte("metainfo") t.Log(string(blah)) comm1.BroadcastMeta(blah) }