commit
f19148d765
@ -22,7 +22,7 @@
|
||||
clients = "3"
|
||||
miners = "2"
|
||||
genesis_timestamp_offset = "0"
|
||||
balance = "2000000000" ## be careful, this is in FIL.
|
||||
balance = "20000000.5"
|
||||
sectors = "10"
|
||||
random_beacon_type = "mock"
|
||||
mining_mode = "natural"
|
||||
|
@ -35,7 +35,7 @@ instances = { min = 1, max = 100, default = 5 }
|
||||
[testcases.params]
|
||||
clients = { type = "int", default = 1 }
|
||||
miners = { type = "int", default = 1 }
|
||||
balance = { type = "int", default = 1 }
|
||||
balance = { type = "float", default = 1 }
|
||||
sectors = { type = "int", default = 1 }
|
||||
role = { type = "string" }
|
||||
|
||||
@ -64,7 +64,7 @@ instances = { min = 1, max = 100, default = 5 }
|
||||
[testcases.params]
|
||||
clients = { type = "int", default = 1 }
|
||||
miners = { type = "int", default = 1 }
|
||||
balance = { type = "int", default = 1 }
|
||||
balance = { type = "float", default = 1 }
|
||||
sectors = { type = "int", default = 1 }
|
||||
role = { type = "string" }
|
||||
genesis_timestamp_offset = { type = "int", default = 0 }
|
||||
@ -94,7 +94,7 @@ instances = { min = 1, max = 100, default = 5 }
|
||||
[testcases.params]
|
||||
clients = { type = "int", default = 1 }
|
||||
miners = { type = "int", default = 1 }
|
||||
balance = { type = "int", default = 1 }
|
||||
balance = { type = "float", default = 1 }
|
||||
sectors = { type = "int", default = 1 }
|
||||
role = { type = "string" }
|
||||
|
||||
@ -127,7 +127,7 @@ instances = { min = 1, max = 100, default = 5 }
|
||||
[testcases.params]
|
||||
clients = { type = "int", default = 1 }
|
||||
miners = { type = "int", default = 1 }
|
||||
balance = { type = "int", default = 1 }
|
||||
balance = { type = "float", default = 1 }
|
||||
sectors = { type = "int", default = 1 }
|
||||
role = { type = "string" }
|
||||
genesis_timestamp_offset = { type = "int", default = 0 }
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
mbig "math/big"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
@ -57,11 +58,12 @@ func PrepareBootstrapper(t *TestEnvironment) (*Bootstrapper, error) {
|
||||
|
||||
totalBalance := big.Zero()
|
||||
for _, b := range balances {
|
||||
totalBalance = big.Add(big.NewInt(int64(b.Balance)), totalBalance)
|
||||
totalBalance = big.Add(filToAttoFil(b.Balance), totalBalance)
|
||||
}
|
||||
|
||||
t.RecordMessage("TOTAL BALANCE: %s", totalBalance)
|
||||
if max := types.TotalFilecoinInt; totalBalance.GreaterThanEqual(max) {
|
||||
totalBalanceFil := attoFilToFil(totalBalance)
|
||||
t.RecordMessage("TOTAL BALANCE: %s AttoFIL (%s FIL)", totalBalance, totalBalanceFil)
|
||||
if max := types.TotalFilecoinInt; totalBalanceFil.GreaterThanEqual(max) {
|
||||
panic(fmt.Sprintf("total sum of balances is greater than max Filecoin ever; sum=%s, max=%s", totalBalance, max))
|
||||
}
|
||||
|
||||
@ -76,7 +78,7 @@ func PrepareBootstrapper(t *TestEnvironment) (*Bootstrapper, error) {
|
||||
var genesisMiners []genesis.Miner
|
||||
|
||||
for _, bm := range balances {
|
||||
balance := big.Mul(big.NewInt(int64(bm.Balance)), types.NewInt(build.FilecoinPrecision))
|
||||
balance := filToAttoFil(bm.Balance)
|
||||
t.RecordMessage("balance assigned to actor %s: %s AttoFIL", bm.Addr, balance)
|
||||
genesisActors = append(genesisActors,
|
||||
genesis.Actor{
|
||||
@ -178,3 +180,18 @@ func (b *Bootstrapper) RunDefault() error {
|
||||
b.t.SyncClient.MustSignalAndWait(ctx, StateDone, b.t.TestInstanceCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
// filToAttoFil converts a fractional filecoin value into AttoFIL, rounding if necessary
|
||||
func filToAttoFil(f float64) big.Int {
|
||||
a := mbig.NewFloat(f)
|
||||
a.Mul(a, mbig.NewFloat(float64(build.FilecoinPrecision)))
|
||||
i, _ := a.Int(nil)
|
||||
return big.Int{Int: i}
|
||||
}
|
||||
|
||||
func attoFilToFil(atto big.Int) big.Int {
|
||||
i := big.NewInt(0)
|
||||
i.Add(i.Int, atto.Int)
|
||||
i.Div(i.Int, big.NewIntUnsigned(build.FilecoinPrecision).Int)
|
||||
return i
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ func PrepareClient(t *TestEnvironment) (*LotusClient, error) {
|
||||
}
|
||||
|
||||
// publish the account ID/balance
|
||||
balance := t.IntParam("balance")
|
||||
balance := t.FloatParam("balance")
|
||||
balanceMsg := &InitialBalanceMsg{Addr: walletKey.Address, Balance: balance}
|
||||
t.SyncClient.Publish(ctx, BalanceTopic, balanceMsg)
|
||||
|
||||
|
@ -63,7 +63,7 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
|
||||
}
|
||||
|
||||
// publish the account ID/balance
|
||||
balance := t.IntParam("balance")
|
||||
balance := t.FloatParam("balance")
|
||||
balanceMsg := &InitialBalanceMsg{Addr: walletKey.Address, Balance: balance}
|
||||
t.SyncClient.Publish(ctx, BalanceTopic, balanceMsg)
|
||||
|
||||
|
@ -27,7 +27,7 @@ var (
|
||||
|
||||
type InitialBalanceMsg struct {
|
||||
Addr address.Address
|
||||
Balance int
|
||||
Balance float64
|
||||
}
|
||||
|
||||
type PresealMsg struct {
|
||||
|
Loading…
Reference in New Issue
Block a user