Commit 3afb562e authored by refcell's avatar refcell Committed by GitHub

fix(op-dispute-mon): credit enriching (#9943)

parent 39252fc2
...@@ -29,9 +29,10 @@ func NewBondEnricher() *BondEnricher { ...@@ -29,9 +29,10 @@ func NewBondEnricher() *BondEnricher {
func (b *BondEnricher) Enrich(ctx context.Context, block rpcblock.Block, caller GameCaller, game *monTypes.EnrichedGameData) error { func (b *BondEnricher) Enrich(ctx context.Context, block rpcblock.Block, caller GameCaller, game *monTypes.EnrichedGameData) error {
recipients := make(map[common.Address]bool) recipients := make(map[common.Address]bool)
for _, claim := range game.Claims { for _, claim := range game.Claims {
recipients[claim.Claimant] = true
if claim.CounteredBy != (common.Address{}) { if claim.CounteredBy != (common.Address{}) {
recipients[claim.CounteredBy] = true recipients[claim.CounteredBy] = true
} else {
recipients[claim.Claimant] = true
} }
} }
......
...@@ -65,7 +65,6 @@ func TestBondEnricher(t *testing.T) { ...@@ -65,7 +65,6 @@ func TestBondEnricher(t *testing.T) {
t.Run("GetCreditsSuccess", func(t *testing.T) { t.Run("GetCreditsSuccess", func(t *testing.T) {
game := makeGame() game := makeGame()
expectedRecipients := []common.Address{ expectedRecipients := []common.Address{
game.Claims[0].Claimant,
game.Claims[0].CounteredBy, game.Claims[0].CounteredBy,
game.Claims[1].Claimant, game.Claims[1].Claimant,
// Claim 1 CounteredBy is unset // Claim 1 CounteredBy is unset
...@@ -74,9 +73,8 @@ func TestBondEnricher(t *testing.T) { ...@@ -74,9 +73,8 @@ func TestBondEnricher(t *testing.T) {
} }
enricher := NewBondEnricher() enricher := NewBondEnricher()
expectedCredits := map[common.Address]*big.Int{ expectedCredits := map[common.Address]*big.Int{
expectedRecipients[0]: big.NewInt(10), expectedRecipients[0]: big.NewInt(20),
expectedRecipients[1]: big.NewInt(20), expectedRecipients[1]: big.NewInt(30),
expectedRecipients[2]: big.NewInt(30),
} }
caller := &mockGameCaller{credits: expectedCredits} caller := &mockGameCaller{credits: expectedCredits}
err := enricher.Enrich(context.Background(), rpcblock.Latest, caller, game) err := enricher.Enrich(context.Background(), rpcblock.Latest, caller, game)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment