fix flaky test (miner#TestMessageFiltering). (#2411)
This commit is contained in:
parent
59b2908620
commit
86457e5201
@ -9,7 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
address "github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
@ -588,6 +588,14 @@ func SelectMessages(ctx context.Context, al ActorLookup, ts *types.TipSet, msgs
|
|||||||
|
|
||||||
gasLimitLeft := int64(build.BlockGasLimit)
|
gasLimitLeft := int64(build.BlockGasLimit)
|
||||||
|
|
||||||
|
orderedSenders := make([]address.Address, 0, len(outBySender))
|
||||||
|
for k := range outBySender {
|
||||||
|
orderedSenders = append(orderedSenders, k)
|
||||||
|
}
|
||||||
|
sort.Slice(orderedSenders, func(i, j int) bool {
|
||||||
|
return bytes.Compare(orderedSenders[i].Bytes(), orderedSenders[j].Bytes()) == -1
|
||||||
|
})
|
||||||
|
|
||||||
out := make([]*types.SignedMessage, 0, build.BlockMessageLimit)
|
out := make([]*types.SignedMessage, 0, build.BlockMessageLimit)
|
||||||
{
|
{
|
||||||
for {
|
for {
|
||||||
@ -596,7 +604,11 @@ func SelectMessages(ctx context.Context, al ActorLookup, ts *types.TipSet, msgs
|
|||||||
var bestGasToReward float64
|
var bestGasToReward float64
|
||||||
|
|
||||||
// TODO: This is O(n^2)-ish, could use something like container/heap to cache this math
|
// TODO: This is O(n^2)-ish, could use something like container/heap to cache this math
|
||||||
for sender, meta := range outBySender {
|
for _, sender := range orderedSenders {
|
||||||
|
meta, ok := outBySender[sender]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for n := range meta.msgs {
|
for n := range meta.msgs {
|
||||||
if meta.gasLimit[n] > gasLimitLeft {
|
if meta.gasLimit[n] > gasLimitLeft {
|
||||||
break
|
break
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ func TestMessageFiltering(t *testing.T) {
|
|||||||
To: a1,
|
To: a1,
|
||||||
Nonce: 2,
|
Nonce: 2,
|
||||||
Value: types.NewInt(150),
|
Value: types.NewInt(150),
|
||||||
GasLimit: (100),
|
GasLimit: 100,
|
||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -89,8 +90,8 @@ func TestMessageFiltering(t *testing.T) {
|
|||||||
t.Fatal("filtering didnt work as expected")
|
t.Fatal("filtering didnt work as expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
m1 := outmsgs[2].Message
|
was, expected := outmsgs[0].Message, msgs[2]
|
||||||
if m1.From != msgs[2].From || m1.Nonce != msgs[2].Nonce {
|
if was.From != expected.From || was.Nonce != expected.Nonce {
|
||||||
t.Fatal("filtering bad")
|
t.Fatal("filtering bad")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user