Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit c27dc0f

Browse files
committed
Fix tests after solcJ update
1 parent d8ecb5e commit c27dc0f

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

ethereumj-core/src/main/java/org/ethereum/util/blockchain/StandaloneBlockchain.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
1717
*/
1818
package org.ethereum.util.blockchain;
1919

20+
import org.ethereum.config.BlockchainConfig;
2021
import org.ethereum.config.BlockchainNetConfig;
2122
import org.ethereum.config.SystemProperties;
23+
import org.ethereum.config.blockchain.ByzantiumConfig;
24+
import org.ethereum.config.blockchain.DaoHFConfig;
25+
import org.ethereum.config.blockchain.DaoNoHFConfig;
2226
import org.ethereum.config.blockchain.FrontierConfig;
27+
import org.ethereum.config.blockchain.HomesteadConfig;
2328
import org.ethereum.core.*;
2429
import org.ethereum.core.genesis.GenesisLoader;
2530
import org.ethereum.crypto.ECKey;
@@ -756,12 +761,12 @@ public synchronized void updateBatch(Map<byte[], byte[]> rows) {
756761
}
757762

758763
// Override blockchain net config for fast mining
759-
public static FrontierConfig getEasyMiningConfig() {
760-
return new FrontierConfig(new FrontierConfig.FrontierConstants() {
764+
public static ByzantiumConfig getEasyMiningConfig() {
765+
return new ByzantiumConfig(new DaoNoHFConfig(new HomesteadConfig(new HomesteadConfig.HomesteadConstants() {
761766
@Override
762767
public BigInteger getMINIMUM_DIFFICULTY() {
763768
return BigInteger.ONE;
764769
}
765-
});
770+
}), 0));
766771
}
767772
}

ethereumj-core/src/test/java/org/ethereum/config/DaoLightMiningTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private String getData(StandaloneBlockchain sb, long blockNumber) {
7474

7575
private StandaloneBlockchain createBlockchain(boolean proFork) {
7676
final BaseNetConfig netConfig = new BaseNetConfig();
77-
final FrontierConfig c1 = StandaloneBlockchain.getEasyMiningConfig();
77+
final BlockchainConfig c1 = StandaloneBlockchain.getEasyMiningConfig();
7878
netConfig.add(0, StandaloneBlockchain.getEasyMiningConfig());
7979
netConfig.add(FORK_BLOCK, proFork ? new DaoHFConfig(c1, FORK_BLOCK) : new DaoNoHFConfig(c1, FORK_BLOCK));
8080

ethereumj-core/src/test/java/org/ethereum/core/ImportLightTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ public void operateNotExistingContractTest() throws IOException, InterruptedExce
513513

514514
// checking balance of not existed address should take
515515
// less that gas limit
516-
Assert.assertEquals(21532, spent);
516+
Assert.assertTrue(spent < 100_000);
517517
}
518518

519519
{
@@ -526,7 +526,10 @@ public void operateNotExistingContractTest() throws IOException, InterruptedExce
526526
// invalid jump error occurred
527527
// all gas wasted
528528
// (for history: it is worked fine in ^0.3.1)
529-
Assert.assertEquals(5_000_000L, spent);
529+
// Assert.assertEquals(5_000_000L, spent);
530+
531+
// FIX for 0.4.25 and apparently some earlier versions
532+
Assert.assertTrue(spent < 100_000);
530533
}
531534
}
532535

@@ -602,7 +605,7 @@ public void rollbackInternalTx() throws Exception {
602605
" uint public b;" +
603606
" function f() {" +
604607
" b = 1;" +
605-
" this.call(bytes4(sha3('exception()')));" +
608+
" this.call.gas(10000)(bytes4(sha3('exception()')));" +
606609
" a = 2;" +
607610
" }" +
608611

@@ -638,7 +641,7 @@ public void selfdestructAttack() throws Exception {
638641
" function f() {" +
639642
" B b = new B();" +
640643
" for (uint i = 0; i < 3500; i++) {" +
641-
" b.suicide(address(i));" +
644+
" b.suicide.gas(10000)(address(i));" +
642645
" }" +
643646
" a = 2;" +
644647
" }" +
@@ -866,12 +869,12 @@ public void functionTypeTest() throws IOException, InterruptedException {
866869
"contract A {" +
867870
" int public res;" +
868871
" function calc(int b, function (int a) external returns (int) f) external returns (int) {" +
869-
" return f(b);" +
872+
" return f.gas(10000)(b);" +
870873
" }" +
871874
" function fInc(int a) external returns (int) { return a + 1;}" +
872875
" function fDec(int a) external returns (int) { return a - 1;}" +
873876
" function test() {" +
874-
" res = this.calc(111, this.fInc);" +
877+
" res = this.calc.gas(100000)(111, this.fInc);" +
875878
" }" +
876879
"}";
877880

@@ -880,7 +883,7 @@ public void functionTypeTest() throws IOException, InterruptedException {
880883
bc.createBlock();
881884
a.callFunction("test");
882885
bc.createBlock();
883-
Assert.assertEquals(a.callConstFunction("res")[0], BigInteger.valueOf(112));
886+
Assert.assertEquals(BigInteger.valueOf(112), a.callConstFunction("res")[0]);
884887

885888
BigInteger r1 = (BigInteger) a.callConstFunction("calc", 222, a.getFunction("fInc"))[0];
886889
Assert.assertEquals(223, r1.intValue());

ethereumj-core/src/test/java/org/ethereum/core/TransactionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,10 @@ public void multiSuicideTest() throws IOException, InterruptedException {
563563
" }" +
564564
" function multipleHomocide() {" +
565565
" PsychoKiller k = this;" +
566-
" k.homicide();" +
567-
" k.homicide();" +
568-
" k.homicide();" +
569-
" k.homicide();" +
566+
" k.homicide.gas(10000)();" +
567+
" k.homicide.gas(10000)();" +
568+
" k.homicide.gas(10000)();" +
569+
" k.homicide.gas(10000)();" +
570570
" }" +
571571
"}";
572572
SolidityCompiler.Result res = SolidityCompiler.compile(

0 commit comments

Comments
 (0)