Mostly fix TestDealFlow
This commit is contained in:
parent
d45544c90c
commit
29778cd653
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -17,6 +18,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDealFlow(t *testing.T, b APIBuilder) {
|
func TestDealFlow(t *testing.T, b APIBuilder) {
|
||||||
|
os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
|
||||||
logging.SetAllLoggers(logging.LevelInfo)
|
logging.SetAllLoggers(logging.LevelInfo)
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
n, sn := b(t, 1, []int{0})
|
n, sn := b(t, 1, []int{0})
|
||||||
@ -46,10 +49,14 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
|
|||||||
|
|
||||||
fmt.Println("FILE CID: ", fcid)
|
fmt.Println("FILE CID: ", fcid)
|
||||||
|
|
||||||
|
mine := true
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for i := 0; i < 4; i++ {
|
defer close(done)
|
||||||
|
for mine {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
fmt.Println("mining a block now", i)
|
fmt.Println("mining a block now")
|
||||||
if err := n[0].MineOne(ctx); err != nil {
|
if err := n[0].MineOne(ctx); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -62,6 +69,7 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
|
|||||||
|
|
||||||
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
loop:
|
||||||
for {
|
for {
|
||||||
di, err := client.ClientGetDealInfo(ctx, *deal)
|
di, err := client.ClientGetDealInfo(ctx, *deal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -76,9 +84,13 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
|
|||||||
t.Fatal("deal errored")
|
t.Fatal("deal errored")
|
||||||
case api.DealComplete:
|
case api.DealComplete:
|
||||||
fmt.Println("COMPLETE", di)
|
fmt.Println("COMPLETE", di)
|
||||||
break
|
break loop
|
||||||
}
|
}
|
||||||
fmt.Println("Deal state: ", di.State)
|
fmt.Println("Deal state: ", api.DealStates[di.State])
|
||||||
time.Sleep(time.Second / 2)
|
time.Sleep(time.Second / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mine = false
|
||||||
|
fmt.Println("shutting down mining")
|
||||||
|
<-done
|
||||||
}
|
}
|
||||||
|
11
api/types.go
11
api/types.go
@ -25,6 +25,17 @@ const (
|
|||||||
DealNoUpdate = DealUnknown
|
DealNoUpdate = DealUnknown
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DealStates = []string{
|
||||||
|
"DealUnknown",
|
||||||
|
"DealRejected",
|
||||||
|
"DealAccepted",
|
||||||
|
"DealStaged",
|
||||||
|
"DealSealing",
|
||||||
|
"DealFailed",
|
||||||
|
"DealComplete",
|
||||||
|
"DealError",
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: check if this exists anywhere else
|
// TODO: check if this exists anywhere else
|
||||||
type MultiaddrSlice []ma.Multiaddr
|
type MultiaddrSlice []ma.Multiaddr
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ func HandleIncomingBlocks(ctx context.Context, bsub *pubsub.Subscription, s *cha
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infow("new block over pubsub", "cid", blk.Header.Cid(), "source", msg.GetFrom())
|
log.Debugw("new block over pubsub", "cid", blk.Header.Cid(), "source", msg.GetFrom())
|
||||||
s.InformNewBlock(msg.GetFrom(), &types.FullBlock{
|
s.InformNewBlock(msg.GetFrom(), &types.FullBlock{
|
||||||
Header: blk.Header,
|
Header: blk.Header,
|
||||||
BlsMessages: bmsgs,
|
BlsMessages: bmsgs,
|
||||||
|
@ -102,7 +102,7 @@ func (syncer *Syncer) InformNewHead(from peer.ID, fts *store.FullTipSet) {
|
|||||||
|
|
||||||
if from == syncer.self {
|
if from == syncer.self {
|
||||||
// TODO: this is kindof a hack...
|
// TODO: this is kindof a hack...
|
||||||
log.Info("got block from ourselves")
|
log.Debug("got block from ourselves")
|
||||||
|
|
||||||
if err := syncer.Sync(ctx, fts.TipSet()); err != nil {
|
if err := syncer.Sync(ctx, fts.TipSet()); err != nil {
|
||||||
log.Errorf("failed to sync our own block %s: %+v", fts.TipSet().Cids(), err)
|
log.Errorf("failed to sync our own block %s: %+v", fts.TipSet().Cids(), err)
|
||||||
@ -907,7 +907,7 @@ func (syncer *Syncer) collectChain(ctx context.Context, ts *types.TipSet) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
syncer.syncState.SetStage(api.StageSyncComplete)
|
syncer.syncState.SetStage(api.StageSyncComplete)
|
||||||
log.Infow("new tipset", "height", ts.Height(), "tipset", types.LogCids(ts.Cids()))
|
log.Debugw("new tipset", "height", ts.Height(), "tipset", types.LogCids(ts.Cids()))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ func (m *Miner) GetBestMiningCandidate(ctx context.Context) (*MiningBase, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, error) {
|
func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, error) {
|
||||||
log.Infow("attempting to mine a block", "tipset", types.LogCids(base.ts.Cids()))
|
log.Debugw("attempting to mine a block", "tipset", types.LogCids(base.ts.Cids()))
|
||||||
ticket, err := m.scratchTicket(ctx, base)
|
ticket, err := m.scratchTicket(ctx, base)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "scratching ticket failed")
|
return nil, errors.Wrap(err, "scratching ticket failed")
|
||||||
|
Loading…
Reference in New Issue
Block a user