-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating how eth_gasPrice is calculated
- Loading branch information
Showing
8 changed files
with
119 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
rskj-core/src/test/java/org/ethereum/facade/EthereumImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.ethereum.facade; | ||
|
||
import co.rsk.core.Coin; | ||
import org.ethereum.core.Block; | ||
import org.ethereum.core.Blockchain; | ||
import org.ethereum.listener.CompositeEthereumListener; | ||
import org.ethereum.listener.GasPriceTracker; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class EthereumImplTest { | ||
Check notice Code scanning / CodeQL Unused classes and interfaces Note test
Unused class: EthereumImplTest is not referenced within this codebase. If not used as an external API it should be removed.
|
||
|
||
|
||
@Test | ||
void getGasPrice_returns_GasPriceTrackerValue_when_feeMarketWorking_is_true() { | ||
GasPriceTracker gasPriceTracker = mock(GasPriceTracker.class); | ||
|
||
when(gasPriceTracker.isFeeMarketWorking()).thenReturn(true); | ||
when(gasPriceTracker.getGasPrice()).thenReturn(Coin.valueOf(10)); | ||
|
||
Ethereum ethereum = new EthereumImpl(null, null, new CompositeEthereumListener(), null, gasPriceTracker, null); | ||
Coin price = ethereum.getGasPrice(); | ||
|
||
assertEquals(10, price.asBigInteger().intValue()); | ||
} | ||
|
||
@Test | ||
void getGasPrice_returns_correctedBestBlockValue_when_feeMarketWorking_is_false(){ | ||
GasPriceTracker gasPriceTracker = mock(GasPriceTracker.class); | ||
Blockchain blockchain = mock(Blockchain.class); | ||
Double minGasPriceMultiplier = 1.2; | ||
Block bestBlock = mock(Block.class); | ||
|
||
when(gasPriceTracker.isFeeMarketWorking()).thenReturn(false); | ||
when(bestBlock.getMinimumGasPrice()).thenReturn(Coin.valueOf(10)); | ||
when(blockchain.getBestBlock()).thenReturn(bestBlock); | ||
|
||
Ethereum ethereum = new EthereumImpl(null, null, new CompositeEthereumListener(), blockchain, gasPriceTracker, minGasPriceMultiplier); | ||
Coin price = ethereum.getGasPrice(); | ||
|
||
assertEquals(12, price.asBigInteger().intValue()); | ||
} | ||
} |