|
7 | 7 | "math/big" |
8 | 8 | "sync" |
9 | 9 |
|
| 10 | + "github.com/ethereum/go-ethereum/common" |
10 | 11 | factoryHasher "github.com/klever-io/klever-go/crypto/hashing/factory" |
11 | 12 | "github.com/klever-io/klever-go/data/transaction" |
12 | 13 | "github.com/klever-io/klever-go/tools" |
@@ -151,3 +152,96 @@ func (mock *KleverBlockchainMock) SendTransactions(ctx context.Context, txs []*t |
151 | 152 |
|
152 | 153 | return hashes, nil |
153 | 154 | } |
| 155 | + |
| 156 | +// AddTokensPair - |
| 157 | +func (mock *KleverBlockchainMock) AddTokensPair(erc20 common.Address, ticker string, isNativeToken, isMintBurnToken bool, totalBalance, mintBalances, burnBalances *big.Int) { |
| 158 | + mock.mutState.Lock() |
| 159 | + defer mock.mutState.Unlock() |
| 160 | + |
| 161 | + mock.addTokensPair(erc20, ticker, isNativeToken, isMintBurnToken, totalBalance, mintBalances, burnBalances) |
| 162 | +} |
| 163 | + |
| 164 | +// SetLastExecutedEthBatchID - |
| 165 | +func (mock *KleverBlockchainMock) SetLastExecutedEthBatchID(lastExecutedEthBatchId uint64) { |
| 166 | + mock.mutState.Lock() |
| 167 | + defer mock.mutState.Unlock() |
| 168 | + |
| 169 | + mock.lastExecutedEthBatchId = lastExecutedEthBatchId |
| 170 | +} |
| 171 | + |
| 172 | +// SetLastExecutedEthTxId - |
| 173 | +func (mock *KleverBlockchainMock) SetLastExecutedEthTxId(lastExecutedEthTxId uint64) { |
| 174 | + mock.mutState.Lock() |
| 175 | + defer mock.mutState.Unlock() |
| 176 | + |
| 177 | + mock.lastExecutedEthTxId = lastExecutedEthTxId |
| 178 | +} |
| 179 | + |
| 180 | +// SetQuorum - |
| 181 | +func (mock *KleverBlockchainMock) SetQuorum(quorum int) { |
| 182 | + mock.mutState.Lock() |
| 183 | + defer mock.mutState.Unlock() |
| 184 | + |
| 185 | + mock.quorum = quorum |
| 186 | +} |
| 187 | + |
| 188 | +// AddRelayer - |
| 189 | +func (mock *KleverBlockchainMock) AddRelayer(address address.Address) { |
| 190 | + mock.mutState.Lock() |
| 191 | + defer mock.mutState.Unlock() |
| 192 | + |
| 193 | + mock.relayers = append(mock.relayers, address.Bytes()) |
| 194 | +} |
| 195 | + |
| 196 | +// PerformedActionID returns the performed action ID |
| 197 | +func (mock *KleverBlockchainMock) PerformedActionID() *big.Int { |
| 198 | + mock.mutState.RLock() |
| 199 | + defer mock.mutState.RUnlock() |
| 200 | + |
| 201 | + return mock.performedAction |
| 202 | +} |
| 203 | + |
| 204 | +// ProposedTransfer returns the proposed transfer that matches the performed action ID |
| 205 | +func (mock *KleverBlockchainMock) ProposedTransfer() *kleverBlockchainProposedTransfer { |
| 206 | + mock.mutState.RLock() |
| 207 | + defer mock.mutState.RUnlock() |
| 208 | + |
| 209 | + if mock.performedAction == nil { |
| 210 | + return nil |
| 211 | + } |
| 212 | + |
| 213 | + for hash, transfer := range mock.proposedTransfers { |
| 214 | + if HashToActionID(hash).String() == mock.performedAction.String() { |
| 215 | + return transfer |
| 216 | + } |
| 217 | + } |
| 218 | + |
| 219 | + return nil |
| 220 | +} |
| 221 | + |
| 222 | +// SetPendingBatch - |
| 223 | +func (mock *KleverBlockchainMock) SetPendingBatch(pendingBatch *KleverBlockchainPendingBatch) { |
| 224 | + mock.mutState.Lock() |
| 225 | + mock.setPendingBatch(pendingBatch) |
| 226 | + mock.mutState.Unlock() |
| 227 | +} |
| 228 | + |
| 229 | +// AddDepositToCurrentBatch - |
| 230 | +func (mock *KleverBlockchainMock) AddDepositToCurrentBatch(deposit KleverBlockchainDeposit) { |
| 231 | + mock.mutState.Lock() |
| 232 | + mock.pendingBatch.KleverBlockchainDeposits = append(mock.pendingBatch.KleverBlockchainDeposits, deposit) |
| 233 | + mock.mutState.Unlock() |
| 234 | +} |
| 235 | + |
| 236 | +// GetAllSentTransactions - |
| 237 | +func (mock *KleverBlockchainMock) GetAllSentTransactions(_ context.Context) map[string]*transaction.Transaction { |
| 238 | + mock.mutState.RLock() |
| 239 | + defer mock.mutState.RUnlock() |
| 240 | + |
| 241 | + txs := make(map[string]*transaction.Transaction) |
| 242 | + for hash, tx := range mock.sentTransactions { |
| 243 | + txs[hash] = tx |
| 244 | + } |
| 245 | + |
| 246 | + return txs |
| 247 | +} |
0 commit comments