-
Notifications
You must be signed in to change notification settings - Fork 339
/
contract.go
52 lines (40 loc) · 1.29 KB
/
contract.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2022 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mock
import (
"context"
"github.com/ethereum/go-ethereum/common"
"math/big"
"github.com/ethersphere/bee/pkg/storageincentives/staking"
)
type stakingContractMock struct {
depositStake func(ctx context.Context, stakedAmount *big.Int) (common.Hash, error)
getStake func(ctx context.Context) (*big.Int, error)
}
func (s *stakingContractMock) DepositStake(ctx context.Context, stakedAmount *big.Int) (common.Hash, error) {
return s.depositStake(ctx, stakedAmount)
}
func (s *stakingContractMock) GetStake(ctx context.Context) (*big.Int, error) {
return s.getStake(ctx)
}
// Option is a an option passed to New
type Option func(mock *stakingContractMock)
// New creates a new mock BatchStore
func New(opts ...Option) staking.Contract {
bs := &stakingContractMock{}
for _, o := range opts {
o(bs)
}
return bs
}
func WithDepositStake(f func(ctx context.Context, stakedAmount *big.Int) (common.Hash, error)) Option {
return func(mock *stakingContractMock) {
mock.depositStake = f
}
}
func WithGetStake(f func(ctx context.Context) (*big.Int, error)) Option {
return func(mock *stakingContractMock) {
mock.getStake = f
}
}