github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/test/compute/bid_rejected_test.go (about) 1 package compute 2 3 import ( 4 "context" 5 6 "github.com/filecoin-project/bacalhau/pkg/compute" 7 "github.com/filecoin-project/bacalhau/pkg/compute/store" 8 "github.com/filecoin-project/bacalhau/pkg/compute/store/resolver" 9 "github.com/google/uuid" 10 ) 11 12 func (s *ComputeSuite) TestBidRejected() { 13 ctx := context.Background() 14 executionID := s.prepareAndAskForBid(ctx, generateJob()) 15 16 _, err := s.node.LocalEndpoint.BidRejected(ctx, compute.BidRejectedRequest{ExecutionID: executionID}) 17 s.NoError(err) 18 err = s.stateResolver.Wait(ctx, executionID, resolver.CheckForState(store.ExecutionStateCancelled)) 19 s.NoError(err) 20 } 21 22 func (s *ComputeSuite) TestBidRejected_DoesntExist() { 23 ctx := context.Background() 24 _, err := s.node.LocalEndpoint.BidRejected(ctx, compute.BidRejectedRequest{ExecutionID: uuid.NewString()}) 25 s.Error(err) 26 } 27 28 func (s *ComputeSuite) TestBidRejected_WrongState() { 29 ctx := context.Background() 30 31 // loop over few states to make sure we don't accept bids, if state is not `Created` 32 for _, state := range []store.ExecutionState{ 33 store.ExecutionStateWaitingVerification, 34 store.ExecutionStatePublishing, 35 store.ExecutionStateCancelled, 36 store.ExecutionStateCompleted, 37 } { 38 executionID := s.prepareAndAskForBid(ctx, generateJob()) 39 err := s.node.ExecutionStore.UpdateExecutionState(ctx, store.UpdateExecutionStateRequest{ 40 ExecutionID: executionID, 41 NewState: state, 42 }) 43 s.NoError(err) 44 45 _, err = s.node.LocalEndpoint.BidRejected(ctx, compute.BidRejectedRequest{ExecutionID: executionID}) 46 s.Error(err) 47 } 48 }