Fix some messagepool tests
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
6562b7a4bc
commit
d6765847df
@ -87,7 +87,7 @@ func (tma *testMpoolAPI) PubSubPublish(string, []byte) error {
|
|||||||
func (tma *testMpoolAPI) StateGetActor(addr address.Address, ts *types.TipSet) (*types.Actor, error) {
|
func (tma *testMpoolAPI) StateGetActor(addr address.Address, ts *types.TipSet) (*types.Actor, error) {
|
||||||
balance, ok := tma.balance[addr]
|
balance, ok := tma.balance[addr]
|
||||||
if !ok {
|
if !ok {
|
||||||
balance = types.NewInt(90000000)
|
balance = types.NewInt(1000e6)
|
||||||
tma.balance[addr] = balance
|
tma.balance[addr] = balance
|
||||||
}
|
}
|
||||||
return &types.Actor{
|
return &types.Actor{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package messagepool
|
package messagepool
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
@ -233,19 +232,7 @@ func (mp *MessagePool) getPendingMessages(curTs, ts *types.TipSet) (map[address.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mp *MessagePool) getGasReward(msg *types.SignedMessage, ts *types.TipSet) *big.Int {
|
func (mp *MessagePool) getGasReward(msg *types.SignedMessage, ts *types.TipSet) *big.Int {
|
||||||
al := func(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.Actor, error) {
|
gasReward := abig.Mul(msg.Message.GasPremium, types.NewInt(uint64(msg.Message.GasLimit)))
|
||||||
return mp.api.StateGetActor(addr, ts)
|
|
||||||
}
|
|
||||||
gasUsed, err := gasguess.GuessGasUsed(context.TODO(), types.EmptyTSK, msg, al)
|
|
||||||
if err != nil {
|
|
||||||
gasUsed = int64(gasguess.MaxGas)
|
|
||||||
if gasUsed > msg.Message.GasLimit/2 {
|
|
||||||
gasUsed = msg.Message.GasLimit / 2
|
|
||||||
}
|
|
||||||
// if we start seeing this warning we may have a problem with spammers!
|
|
||||||
log.Warnf("Cannot guess gas usage for message: %s; using %d", err, gasUsed)
|
|
||||||
}
|
|
||||||
gasReward := abig.Mul(msg.Message.GasPrice, types.NewInt(uint64(gasUsed)))
|
|
||||||
return gasReward.Int
|
return gasReward.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,14 @@ import (
|
|||||||
|
|
||||||
func makeTestMessage(w *wallet.Wallet, from, to address.Address, nonce uint64, gasLimit int64, gasPrice uint64) *types.SignedMessage {
|
func makeTestMessage(w *wallet.Wallet, from, to address.Address, nonce uint64, gasLimit int64, gasPrice uint64) *types.SignedMessage {
|
||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
From: from,
|
From: from,
|
||||||
To: to,
|
To: to,
|
||||||
Method: 2,
|
Method: 2,
|
||||||
Value: types.FromFil(0),
|
Value: types.FromFil(0),
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
GasLimit: gasLimit,
|
GasLimit: gasLimit,
|
||||||
GasPrice: types.NewInt(gasPrice),
|
GasFeeCap: types.NewInt(gasPrice + 100),
|
||||||
|
GasPremium: types.NewInt(gasPrice),
|
||||||
}
|
}
|
||||||
sig, err := w.Sign(context.TODO(), from, msg.Cid().Bytes())
|
sig, err := w.Sign(context.TODO(), from, msg.Cid().Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,12 +23,13 @@ func Address(i uint64) address.Address {
|
|||||||
|
|
||||||
func MkMessage(from, to address.Address, nonce uint64, w *wallet.Wallet) *types.SignedMessage {
|
func MkMessage(from, to address.Address, nonce uint64, w *wallet.Wallet) *types.SignedMessage {
|
||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: to,
|
To: to,
|
||||||
From: from,
|
From: from,
|
||||||
Value: types.NewInt(1),
|
Value: types.NewInt(1),
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
GasLimit: 1000000,
|
GasLimit: 1000000,
|
||||||
GasPrice: types.NewInt(0),
|
GasFeeCap: types.NewInt(100),
|
||||||
|
GasPremium: types.NewInt(1),
|
||||||
}
|
}
|
||||||
|
|
||||||
sig, err := w.Sign(context.TODO(), from, msg.Cid().Bytes())
|
sig, err := w.Sign(context.TODO(), from, msg.Cid().Bytes())
|
||||||
|
Loading…
Reference in New Issue
Block a user