Commit e785e678 authored by Reinaldo de Souza Jr's avatar Reinaldo de Souza Jr
Browse files

Use same tests

They all pass on simple_, some fail on double_ratche.go
parent 26b3dfe8
......@@ -193,37 +193,82 @@ func (e *Entity) sendP2() Msg {
}
func main() {
fmt.Println("=========================")
fmt.Println("Testing fresh DAKE")
fmt.Println("=========================")
var a, b *Entity
runFreshDAKE()
//XXX They are all good so far
if true {
fmt.Println("=========================")
fmt.Println("Testing fresh DAKE")
fmt.Println("=========================")
fmt.Println("=========================")
fmt.Println("Testing sync data message")
fmt.Println("=========================")
runFreshDAKE()
testSyncDataMessages(runFreshDAKE())
fmt.Println("=========================")
fmt.Println("Testing sync data message")
fmt.Println("=========================")
fmt.Println("=========================")
fmt.Println("Testing async data message")
fmt.Println("=========================")
testSyncDataMessages(runFreshDAKE())
fmt.Println("=========================")
fmt.Println("Testing async data message")
fmt.Println("=========================")
testAsyncDataMessages(runFreshDAKE())
fmt.Println("=========================")
fmt.Println("Testing new sync DAKE")
fmt.Println("=========================")
testAsyncDataMessages(runFreshDAKE())
// a sends first, will start a new ratchet
testSyncDataMessages(runFreshDAKE())
a, b = runFreshDAKE()
// b sends first, meaning it should start by sending a follow up msg
testSyncDataMessages(b, a)
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - Late msg is a follow up")
fmt.Println("=========================")
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(b, a) // Bob should not ratchet because he sends first
}
fmt.Println("=========================")
fmt.Println("Testing new sync DAKE")
fmt.Println("Testing async DAKE message - Late msg is a new RATCHET")
fmt.Println("=========================")
// a sends first, will start a new ratchet
testSyncDataMessages(runFreshDAKE())
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
b.receive(a.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
a, b := runFreshDAKE()
// b sends first, meaning it should start by sending a follow up msg
testSyncDataMessages(b, a)
//B will send a late msg during a new DAKE.
b.receive(a.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(b, a) // Bob should not ratchet because he sends first
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - Late msg is a follow up")
fmt.Println("Testing async DAKE message - Alice receive late after she ratchet")
fmt.Println("=========================")
a, b = runFreshDAKE()
......@@ -231,21 +276,37 @@ func main() {
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b)
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKEAfterSheRatchetsAgain(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKEAfterSheRatchetsAgain(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - Late msg is a new RATCHET")
fmt.Println("Testing async DAKE message - RATCHET over DAKE")
fmt.Println("=========================")
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
b.receive(a.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b)
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_AliceReceivesLateNewRathcetMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_AliceReceivesLateNewRathcetMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
//
// OLD TEST
//
......@@ -366,7 +427,7 @@ func testAsyncDataMessages(a, b *Entity) {
// NOTE The late message may or may not be a follow up.
// NOTE Bob does not receive any message after starting the DAKE.
// NOTE Bob does not receive any late messages after both finish the DAKE.
func testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b *Entity) {
func testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b *Entity) {
b.receive(a.query())
p1 := b.sendP1()
......@@ -387,3 +448,54 @@ func testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b *Entity) {
// NOTE Bob does not receive any late messages from Alice.
// This can only happen if she do not receive P1.
}
// NOTE The late message may or may not be a follow up.
// NOTE Bob does not receive any message after starting the DAKE.
// NOTE Bob does not receive any late messages after both finish the DAKE.
// NOTE Alice will start a NEW ratchet before reeives the late message.
func testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKEAfterSheRatchetsAgain(a, b *Entity) {
b.receive(a.query())
p1 := b.sendP1()
// Bob sends a message which wiill be delivered late. It can be a follow up or not.
late := b.sendData()
b.receive(a.sendData()) // Alice starts a NEW ratchet.
// NOTE Bob does not receive any message after starting the DAKE.
a.receive(p1) // a receives p1
p2 := a.sendP2() // ... and immediately replies with a p2. The DAKE finishes for Alice.
late_from_receiver := a.sendData() // This should make Alice ratchet
// Alice receives the late message after finishing the DAKE
a.receive(late)
// AKE finishes for Bob.
b.receive(p2)
b.receive(late_from_receiver)
// NOTE Bob does not receive any late messages from Alice.
// This can only happen if she do not receive P1.
}
func testAsyncDAKE_AliceReceivesLateNewRathcetMsgFromPreviousDAKE(a, b *Entity) {
b.receive(a.query())
p1 := b.sendP1()
late := b.sendData() // Bob sends late. Can be NEW ratchet or follow up.
b.receive(a.sendData()) // Bob receives from Alice. If "late" is a follow up, this is a NEW ratchet. This is a follow up otherwise.
late2 := b.sendData() // Bob sends late2. This is always a NEW dake (he has just receive something from Alice).
b.receive(a.sendData()) // Alice sends a follow up (she hasnt received anything from Bob), since her last message.
a.receive(p1) // a receives p1
p2 := a.sendP2() // ... and immediately replies with a p2. The DAKE finishes for Alice.
// AKE finishes for Bob.
b.receive(p2)
// Alice receives the late message after finishing the DAKE
a.receive(late)
a.receive(late2)
}
......@@ -275,49 +275,54 @@ func (e *Entity) query() Msg {
func main() {
var a, b *Entity
//XXX They are all good so far
if true {
fmt.Println("=========================")
fmt.Println("Testing fresh DAKE")
fmt.Println("=========================")
fmt.Println("=========================")
fmt.Println("Testing fresh DAKE")
fmt.Println("=========================")
runFreshDAKE()
fmt.Println("=========================")
fmt.Println("Testing sync data message")
fmt.Println("=========================")
runFreshDAKE()
testSyncDataMessages(runFreshDAKE())
fmt.Println("=========================")
fmt.Println("Testing sync data message")
fmt.Println("=========================")
fmt.Println("=========================")
fmt.Println("Testing async data message")
fmt.Println("=========================")
testSyncDataMessages(runFreshDAKE())
testAsyncDataMessages(runFreshDAKE())
fmt.Println("=========================")
fmt.Println("Testing async data message")
fmt.Println("=========================")
fmt.Println("=========================")
fmt.Println("Testing new sync DAKE")
fmt.Println("=========================")
testAsyncDataMessages(runFreshDAKE())
// a sends first, will start a new ratchet
testSyncDataMessages(runFreshDAKE())
fmt.Println("=========================")
fmt.Println("Testing new sync DAKE")
fmt.Println("=========================")
a, b = runFreshDAKE()
// b sends first, meaning it should start by sending a follow up msg
testSyncDataMessages(b, a)
// a sends first, will start a new ratchet
testSyncDataMessages(runFreshDAKE())
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - Late msg is a follow up")
fmt.Println("=========================")
a, b = runFreshDAKE()
// b sends first, meaning it should start by sending a follow up msg
testSyncDataMessages(b, a)
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - Late msg is a follow up")
fmt.Println("=========================")
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b)
}
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(b, a) // Bob should not ratchet because he sends first
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - Late msg is a new RATCHET")
......@@ -328,9 +333,57 @@ func main() {
//B will send a late msg during a new DAKE.
b.receive(a.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b)
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
b.receive(a.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b)
testSyncDataMessages(b, a) // Bob should not ratchet because he sends first
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - Alice receive late after she ratchet")
fmt.Println("=========================")
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKEAfterSheRatchetsAgain(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKEAfterSheRatchetsAgain(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
fmt.Println("=========================")
fmt.Println("Testing async DAKE message - RATCHET over DAKE")
fmt.Println("=========================")
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a follow up
testAsyncDAKE_AliceReceivesLateNewRathcetMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
a, b = runFreshDAKE()
testSyncDataMessages(a, b)
//B will send a late msg during a new DAKE.
a.receive(b.sendData()) //Make sure late msg is a new RATCHET
testAsyncDAKE_AliceReceivesLateNewRathcetMsgFromPreviousDAKE(a, b)
testSyncDataMessages(a, b) // Alice should ratchet because she sends first
//
// OLD TEST
//
......@@ -453,7 +506,7 @@ func testAsyncDataMessages(a, b *Entity) {
// NOTE The late message may or may not be a follow up.
// NOTE Bob does not receive any message after starting the DAKE.
// NOTE Bob does not receive any late messages after both finish the DAKE.
func testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b *Entity) {
func testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKE(a, b *Entity) {
b.receive(a.query())
p1 := b.sendP1()
......@@ -474,3 +527,54 @@ func testAsyncDAKE_InitiatorReceivesLateMsgFromPreviousDAKE(a, b *Entity) {
// NOTE Bob does not receive any late messages from Alice.
// This can only happen if she do not receive P1.
}
// NOTE The late message may or may not be a follow up.
// NOTE Bob does not receive any message after starting the DAKE.
// NOTE Bob does not receive any late messages after both finish the DAKE.
// NOTE Alice will start a NEW ratchet before reeives the late message.
func testAsyncDAKE_AliceReceivesLateMsgFromPreviousDAKEAfterSheRatchetsAgain(a, b *Entity) {
b.receive(a.query())
p1 := b.sendP1()
// Bob sends a message which wiill be delivered late. It can be a follow up or not.
late := b.sendData()
b.receive(a.sendData()) // Alice starts a NEW ratchet.
// NOTE Bob does not receive any message after starting the DAKE.
a.receive(p1) // a receives p1
p2 := a.sendP2() // ... and immediately replies with a p2. The DAKE finishes for Alice.
late_from_receiver := a.sendData() // This should make Alice ratchet
// Alice receives the late message after finishing the DAKE
a.receive(late)
// AKE finishes for Bob.
b.receive(p2)
b.receive(late_from_receiver)
// NOTE Bob does not receive any late messages from Alice.
// This can only happen if she do not receive P1.
}
func testAsyncDAKE_AliceReceivesLateNewRathcetMsgFromPreviousDAKE(a, b *Entity) {
b.receive(a.query())
p1 := b.sendP1()
late := b.sendData() // Bob sends late. Can be NEW ratchet or follow up.
b.receive(a.sendData()) // Bob receives from Alice. If "late" is a follow up, this is a NEW ratchet. This is a follow up otherwise.
late2 := b.sendData() // Bob sends late2. This is always a NEW dake (he has just receive something from Alice).
b.receive(a.sendData()) // Alice sends a follow up (she hasnt received anything from Bob), since her last message.
a.receive(p1) // a receives p1
p2 := a.sendP2() // ... and immediately replies with a p2. The DAKE finishes for Alice.
// AKE finishes for Bob.
b.receive(p2)
// Alice receives the late message after finishing the DAKE
a.receive(late)
a.receive(late2)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment