mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm: fixed review comments
This commit is contained in:
parent
e065811f7f
commit
ab9556dfe5
1 changed files with 16 additions and 23 deletions
|
|
@ -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,24 +204,20 @@ 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...
|
log.Trace(fmt.Sprintf("balance of %s with %s: %d", k.TerminalString(), n.TerminalString(), balanceKwithN))
|
||||||
if n == subK {
|
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", k.TerminalString(), n.TerminalString(), balanceKwithN))
|
//...check that they have the same balance in Abs terms and that it is not 0
|
||||||
log.Trace(fmt.Sprintf("balance of %s with %s: %d", n.TerminalString(), k.TerminalString(), mapForSubK[k]))
|
if balanceKwithN+mapForSubK[k] != 0 && balanceKwithN != 0 {
|
||||||
//...check that they have the same balance in Abs terms and that it is not 0
|
log.Error(fmt.Sprintf("Expected balances to be a+b = 0 AND balance(a) != 0, but they are not, balance k with n: %d, balance n with k: %d", balanceKwithN, mapForSubK[k]))
|
||||||
if balanceKwithN+mapForSubK[k] != 0 && balanceKwithN != 0 {
|
success = false
|
||||||
log.Error(fmt.Sprintf("Expected balances to be a+b = 0 AND balance(a) != 0, but they are not, balance k with n: %d, balance n with k: %d", balanceKwithN, mapForSubK[k]))
|
|
||||||
success = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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,15 +371,12 @@ 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 {
|
log.Error(fmt.Sprintf("Expected balances to be a+b = 0 AND balance(a) != 0, but they are not, balance k with n: %d, balance n with k: %d", balanceKwithN, mapForSubK[k]))
|
||||||
log.Error(fmt.Sprintf("Expected balances to be a+b = 0 AND balance(a) != 0, but they are not, balance k with n: %d, balance n with k: %d", balanceKwithN, mapForSubK[k]))
|
success = false
|
||||||
success = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue