Skip to content

Commit

Permalink
Missing ids dispute fix (#670)
Browse files Browse the repository at this point in the history
* fixed missingDisputeFix

* fixed tests
  • Loading branch information
Yashk767 authored Apr 7, 2022
1 parent 457fede commit a0fb9bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/dispute.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ func (*UtilsStruct) CheckDisputeForIds(client *ethclient.Client, transactionOpts
transactionOpts.MethodName = "disputeCollectionIdShouldBePresent"
transactionOpts.Parameters = []interface{}{epoch, blockIndex, missingCollectionId}
txnOpts := razorUtils.GetTxnOpts(transactionOpts)
gasLimit := txnOpts.GasLimit
incrementedGasLimit, err := utilsInterface.IncreaseGasLimitValue(client, gasLimit, 5.5)
if err != nil {
return nil, err
}
txnOpts.GasLimit = incrementedGasLimit
log.Debug("Disputing collection id should be present!")
log.Debugf("Epoch: %d, blockIndex: %d, missingCollectionId: %d", epoch, blockIndex, missingCollectionId)
return blockManagerUtils.DisputeCollectionIdShouldBePresent(client, txnOpts, epoch, blockIndex, missingCollectionId)
Expand Down
2 changes: 2 additions & 0 deletions cmd/dispute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ func TestCheckDisputeForIds(t *testing.T) {
utils.UtilsInterface = utilsPkgMock
razorUtils = utilsMock
blockManagerUtils = blockManagerUtilsMock
utilsInterface = utilsPkgMock

utilsPkgMock.On("IsSorted", mock.Anything).Return(tt.args.isSorted, tt.args.index0, tt.args.index1)
utilsMock.On("GetTxnOpts", mock.AnythingOfType("types.TransactionOptions")).Return(txnOpts)
Expand All @@ -779,6 +780,7 @@ func TestCheckDisputeForIds(t *testing.T) {
blockManagerUtilsMock.On("DisputeCollectionIdShouldBePresent", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tt.args.DisputeCollectionIdShouldBePresent, tt.args.DisputeCollectionIdShouldBePresentErr)
utilsPkgMock.On("IsMissing", mock.Anything, mock.Anything).Return(tt.args.isPresent, tt.args.positionOfPresentValue, tt.args.presentCollectionId)
blockManagerUtilsMock.On("DisputeCollectionIdShouldBeAbsent", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tt.args.DisputeCollectionIdShouldBeAbsent, tt.args.DisputeCollectionIdShouldBeAbsentErr)
utilsPkgMock.On("IncreaseGasLimitValue", mock.Anything, mock.Anything, mock.Anything).Return(uint64(2000), nil)
ut := &UtilsStruct{}
got, err := ut.CheckDisputeForIds(client, transactionOpts, epoch, blockIndex, tt.args.idsInProposedBlock, tt.args.revealedCollectionIds)
if (err != nil) != tt.wantErr {
Expand Down

0 comments on commit a0fb9bb

Please sign in to comment.