diff --git a/api/test/deals.go b/api/test/deals.go index ea5956458..050f1d0ee 100644 --- a/api/test/deals.go +++ b/api/test/deals.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "math/rand" + "os" "testing" "time" @@ -17,6 +18,8 @@ import ( ) func TestDealFlow(t *testing.T, b APIBuilder) { + os.Setenv("BELLMAN_NO_GPU", "1") + logging.SetAllLoggers(logging.LevelInfo) ctx := context.TODO() n, sn := b(t, 1, []int{0}) @@ -46,10 +49,14 @@ func TestDealFlow(t *testing.T, b APIBuilder) { fmt.Println("FILE CID: ", fcid) + mine := true + done := make(chan struct{}) + go func() { - for i := 0; i < 4; i++ { + defer close(done) + for mine { 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 { 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 time.Sleep(time.Second) + loop: for { di, err := client.ClientGetDealInfo(ctx, *deal) if err != nil { @@ -76,9 +84,13 @@ func TestDealFlow(t *testing.T, b APIBuilder) { t.Fatal("deal errored") case api.DealComplete: 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) } + + mine = false + fmt.Println("shutting down mining") + <-done } diff --git a/api/types.go b/api/types.go index 6a5153328..cd2717bbd 100644 --- a/api/types.go +++ b/api/types.go @@ -25,6 +25,17 @@ const ( DealNoUpdate = DealUnknown ) +var DealStates = []string{ + "DealUnknown", + "DealRejected", + "DealAccepted", + "DealStaged", + "DealSealing", + "DealFailed", + "DealComplete", + "DealError", +} + // TODO: check if this exists anywhere else type MultiaddrSlice []ma.Multiaddr diff --git a/chain/sub/incoming.go b/chain/sub/incoming.go index ddca848e9..5e6c31de1 100644 --- a/chain/sub/incoming.go +++ b/chain/sub/incoming.go @@ -44,7 +44,7 @@ func HandleIncomingBlocks(ctx context.Context, bsub *pubsub.Subscription, s *cha 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{ Header: blk.Header, BlsMessages: bmsgs, diff --git a/chain/sync.go b/chain/sync.go index dac2a79e5..952b57a20 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -102,7 +102,7 @@ func (syncer *Syncer) InformNewHead(from peer.ID, fts *store.FullTipSet) { if from == syncer.self { // 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 { 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) - 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 } diff --git a/miner/miner.go b/miner/miner.go index 9f7c44478..72ec090c7 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -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) { - 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) if err != nil { return nil, errors.Wrap(err, "scratching ticket failed")