swarm: fixed review comments

This commit is contained in:
Fabio Barone 2018-11-30 07:15:43 -05:00
parent e065811f7f
commit ab9556dfe5

View file

@ -146,7 +146,7 @@ func TestSwapNetworkSymmetricFileUpload(t *testing.T) {
} }
} }
time.Sleep(5 * time.Second) time.Sleep(3 * time.Second)
//every node has a map to all nodes it had interactions //every node has a map to all nodes it had interactions
//each entry in the map is a map of the other node with all the balances //each entry in the map is a map of the other node with all the balances
balancesMap := make(map[enode.ID]map[enode.ID]int64) balancesMap := make(map[enode.ID]map[enode.ID]int64)
@ -204,9 +204,7 @@ func TestSwapNetworkSymmetricFileUpload(t *testing.T) {
//iterate the submap //iterate the submap
for n, balanceKwithN := range mapForK { for n, balanceKwithN := range mapForK {
//iterate the main map again //iterate the main map again
for subK, mapForSubK := range balancesMap { mapForSubK := balancesMap[n]
//if the node and the peer are the same...
if n == subK {
log.Trace(fmt.Sprintf("balance of %s with %s: %d", k.TerminalString(), n.TerminalString(), balanceKwithN)) log.Trace(fmt.Sprintf("balance of %s with %s: %d", k.TerminalString(), n.TerminalString(), balanceKwithN))
log.Trace(fmt.Sprintf("balance of %s with %s: %d", n.TerminalString(), k.TerminalString(), mapForSubK[k])) log.Trace(fmt.Sprintf("balance of %s with %s: %d", n.TerminalString(), k.TerminalString(), mapForSubK[k]))
//...check that they have the same balance in Abs terms and that it is not 0 //...check that they have the same balance in Abs terms and that it is not 0
@ -216,12 +214,10 @@ func TestSwapNetworkSymmetricFileUpload(t *testing.T) {
} }
} }
} }
}
}
if success { if success {
return nil return nil
} }
return errors.New("some conditions could not be met") return errors.New("Expected balances to be symmetrical, but they were not")
}) })
if result.Error != nil { if result.Error != nil {
@ -330,7 +326,7 @@ func TestSwapNetworkAsymmetricFileUpload(t *testing.T) {
} }
} }
time.Sleep(5 * time.Second) time.Sleep(3 * time.Second)
balancesMap := make(map[enode.ID]map[enode.ID]int64) balancesMap := make(map[enode.ID]map[enode.ID]int64)
@ -375,8 +371,7 @@ func TestSwapNetworkAsymmetricFileUpload(t *testing.T) {
success := true success := true
for k, mapForK := range balancesMap { for k, mapForK := range balancesMap {
for n, balanceKwithN := range mapForK { for n, balanceKwithN := range mapForK {
for subK, mapForSubK := range balancesMap { mapForSubK := balancesMap[n]
if n == subK {
log.Trace(fmt.Sprintf("balance of %s with %s: %d", k.TerminalString(), n.TerminalString(), balanceKwithN)) log.Trace(fmt.Sprintf("balance of %s with %s: %d", k.TerminalString(), n.TerminalString(), balanceKwithN))
log.Trace(fmt.Sprintf("balance of %s with %s: %d", n.TerminalString(), k.TerminalString(), mapForSubK[k])) log.Trace(fmt.Sprintf("balance of %s with %s: %d", n.TerminalString(), k.TerminalString(), mapForSubK[k]))
if balanceKwithN+mapForSubK[k] != 0 && balanceKwithN != 0 { if balanceKwithN+mapForSubK[k] != 0 && balanceKwithN != 0 {
@ -385,8 +380,6 @@ func TestSwapNetworkAsymmetricFileUpload(t *testing.T) {
} }
} }
} }
}
}
if success { if success {
return nil return nil