Skip to content

Commit

Permalink
remove dummy repo in the precompiledContract test suites and ignored …
Browse files Browse the repository at this point in the history
…the trs test suites
  • Loading branch information
AionJayT committed Apr 26, 2019
1 parent f3d1fad commit d7e0866
Show file tree
Hide file tree
Showing 17 changed files with 568 additions and 373 deletions.
2 changes: 2 additions & 0 deletions modPrecompiled/test/org/aion/precompiled/TRS/TRShelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import org.aion.zero.impl.core.IAionBlockchain;
import org.aion.zero.impl.types.AionBlock;
import org.junit.Assert;
import org.junit.Ignore;

/** A class exposing all helper methods and some variables for TRS-related testing. */
@Ignore
class TRShelpers {
private static final byte[] OUT = new byte[1];
static final BigInteger DEFAULT_BALANCE = BigInteger.TEN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,62 @@
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import org.aion.db.impl.DBVendor;
import org.aion.db.impl.DatabaseFactory;
import org.aion.interfaces.db.ContractDetails;
import org.aion.interfaces.db.PruneConfig;
import org.aion.interfaces.db.RepositoryConfig;
import org.aion.mcf.config.CfgPrune;
import org.aion.types.Address;
import org.aion.precompiled.PrecompiledResultCode;
import org.aion.precompiled.contracts.DummyRepo;
import org.aion.precompiled.contracts.TRS.AbstractTRS;
import org.aion.precompiled.contracts.TRS.TRSuseContract;

import org.aion.zero.impl.db.AionRepositoryCache;
import org.aion.zero.impl.db.AionRepositoryImpl;
import org.aion.zero.impl.db.ContractDetailsAion;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/** A class testing the linked list data structure inside the public-facing TRS contract. */
@Ignore
public class TRSlinkedListTest extends TRShelpers {

@Before
public void setup() {
repo = new DummyRepo();
((DummyRepo) repo).storageErrorReturn = null;
RepositoryConfig repoConfig =
new RepositoryConfig() {
@Override
public String getDbPath() {
return "";
}

@Override
public PruneConfig getPruneConfig() {
return new CfgPrune(false);
}

@Override
public ContractDetails contractDetailsImpl() {
return ContractDetailsAion.createForTesting(0, 1000000).getDetails();
}

@Override
public Properties getDatabaseConfig(String db_name) {
Properties props = new Properties();
props.setProperty(DatabaseFactory.Props.DB_TYPE, DBVendor.MOCKDB.toValue());
props.setProperty(DatabaseFactory.Props.ENABLE_HEAP_CACHE, "false");
return props;
}
};
repo =
new AionRepositoryCache(AionRepositoryImpl.createForTesting(repoConfig));


tempAddrs = new ArrayList<>();
repo.addBalance(AION, BigInteger.ONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,65 @@
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
import java.util.Set;
import org.aion.db.impl.DBVendor;
import org.aion.db.impl.DatabaseFactory;
import org.aion.interfaces.db.ContractDetails;
import org.aion.interfaces.db.PruneConfig;
import org.aion.interfaces.db.RepositoryConfig;
import org.aion.mcf.config.CfgPrune;
import org.aion.types.Address;
import org.aion.mcf.vm.types.DoubleDataWord;
import org.aion.precompiled.PrecompiledResultCode;
import org.aion.precompiled.PrecompiledTransactionResult;
import org.aion.precompiled.contracts.DummyRepo;
import org.aion.precompiled.contracts.TRS.AbstractTRS;
import org.aion.precompiled.contracts.TRS.TRSqueryContract;
import org.aion.precompiled.type.StatefulPrecompiledContract;

import org.aion.util.bytes.ByteUtil;
import org.aion.zero.impl.db.AionRepositoryCache;
import org.aion.zero.impl.db.AionRepositoryImpl;
import org.aion.zero.impl.db.ContractDetailsAion;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/** Tests the TRSqueryContract API. */
@Ignore
public class TRSqueryContractTest extends TRShelpers {
private static final int MAX_OP = 5;

@Before
public void setup() {
repo = new DummyRepo();
((DummyRepo) repo).storageErrorReturn = null;
RepositoryConfig repoConfig =
new RepositoryConfig() {
@Override
public String getDbPath() {
return "";
}

@Override
public PruneConfig getPruneConfig() {
return new CfgPrune(false);
}

@Override
public ContractDetails contractDetailsImpl() {
return ContractDetailsAion.createForTesting(0, 1000000).getDetails();
}

@Override
public Properties getDatabaseConfig(String db_name) {
Properties props = new Properties();
props.setProperty(DatabaseFactory.Props.DB_TYPE, DBVendor.MOCKDB.toValue());
props.setProperty(DatabaseFactory.Props.ENABLE_HEAP_CACHE, "false");
return props;
}
};
repo =
new AionRepositoryCache(AionRepositoryImpl.createForTesting(repoConfig));
tempAddrs = new ArrayList<>();
repo.addBalance(AION, BigInteger.ONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,66 @@
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.aion.db.impl.DBVendor;
import org.aion.db.impl.DatabaseFactory;
import org.aion.interfaces.db.ContractDetails;
import org.aion.interfaces.db.PruneConfig;
import org.aion.interfaces.db.RepositoryConfig;
import org.aion.mcf.config.CfgPrune;
import org.aion.types.Address;
import org.aion.mcf.vm.types.DoubleDataWord;
import org.aion.precompiled.PrecompiledResultCode;
import org.aion.precompiled.PrecompiledTransactionResult;
import org.aion.precompiled.contracts.DummyRepo;
import org.aion.precompiled.contracts.TRS.AbstractTRS;
import org.aion.precompiled.contracts.TRS.TRSstateContract;
import org.aion.precompiled.type.StatefulPrecompiledContract;

import org.aion.util.bytes.ByteUtil;
import org.aion.zero.impl.db.AionRepositoryCache;
import org.aion.zero.impl.db.AionRepositoryImpl;
import org.aion.zero.impl.db.ContractDetailsAion;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/** Tests the TRSstateContract API. */
@Ignore
public class TRSstateContractTest extends TRShelpers {
private static final int MAX_OP = 3;

@Before
public void setup() {
repo = new DummyRepo();
((DummyRepo) repo).storageErrorReturn = null;
RepositoryConfig repoConfig =
new RepositoryConfig() {
@Override
public String getDbPath() {
return "";
}

@Override
public PruneConfig getPruneConfig() {
return new CfgPrune(false);
}

@Override
public ContractDetails contractDetailsImpl() {
return ContractDetailsAion.createForTesting(0, 1000000).getDetails();
}

@Override
public Properties getDatabaseConfig(String db_name) {
Properties props = new Properties();
props.setProperty(DatabaseFactory.Props.DB_TYPE, DBVendor.MOCKDB.toValue());
props.setProperty(DatabaseFactory.Props.ENABLE_HEAP_CACHE, "false");
return props;
}
};
repo =
new AionRepositoryCache(AionRepositoryImpl.createForTesting(repoConfig));

tempAddrs = new ArrayList<>();
repo.addBalance(AION, BigInteger.ONE);
mockBlockchain(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,66 @@
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
import java.util.Set;
import org.aion.db.impl.DBVendor;
import org.aion.db.impl.DatabaseFactory;
import org.aion.interfaces.db.ContractDetails;
import org.aion.interfaces.db.PruneConfig;
import org.aion.interfaces.db.RepositoryConfig;
import org.aion.mcf.config.CfgPrune;
import org.aion.types.Address;
import org.aion.crypto.ECKeyFac;
import org.aion.mcf.vm.types.DoubleDataWord;
import org.aion.precompiled.PrecompiledResultCode;
import org.aion.precompiled.PrecompiledTransactionResult;
import org.aion.precompiled.contracts.DummyRepo;
import org.aion.precompiled.contracts.TRS.AbstractTRS;
import org.aion.precompiled.contracts.TRS.TRSuseContract;
import org.aion.precompiled.type.StatefulPrecompiledContract;

import org.aion.util.bytes.ByteUtil;
import org.aion.zero.impl.db.AionRepositoryCache;
import org.aion.zero.impl.db.AionRepositoryImpl;
import org.aion.zero.impl.db.ContractDetailsAion;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/** Tests the TRSuseContract API. */
@Ignore
public class TRSuseContractTest extends TRShelpers {
private static final int MAX_OP = 6;

@Before
public void setup() {
repo = new DummyRepo();
((DummyRepo) repo).storageErrorReturn = null;
RepositoryConfig repoConfig =
new RepositoryConfig() {
@Override
public String getDbPath() {
return "";
}

@Override
public PruneConfig getPruneConfig() {
return new CfgPrune(false);
}

@Override
public ContractDetails contractDetailsImpl() {
return ContractDetailsAion.createForTesting(0, 1000000).getDetails();
}

@Override
public Properties getDatabaseConfig(String db_name) {
Properties props = new Properties();
props.setProperty(DatabaseFactory.Props.DB_TYPE, DBVendor.MOCKDB.toValue());
props.setProperty(DatabaseFactory.Props.ENABLE_HEAP_CACHE, "false");
return props;
}
};
repo =
new AionRepositoryCache(AionRepositoryImpl.createForTesting(repoConfig));
tempAddrs = new ArrayList<>();
repo.addBalance(AION, BigInteger.ONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
import static org.aion.precompiled.contracts.ATB.BridgeTestUtils.dummyContext;

import java.util.List;
import java.util.Properties;
import org.aion.db.impl.DBVendor;
import org.aion.db.impl.DatabaseFactory;
import org.aion.interfaces.db.ContractDetails;
import org.aion.interfaces.db.PruneConfig;
import org.aion.interfaces.db.RepositoryConfig;
import org.aion.mcf.config.CfgPrune;
import org.aion.types.Address;
import org.aion.crypto.HashUtil;
import org.aion.fastvm.ExecutionContext;
import org.aion.precompiled.contracts.DummyRepo;

import org.aion.util.bytes.ByteUtil;
import org.aion.vm.api.interfaces.IExecutionLog;
import org.aion.vm.api.interfaces.TransactionSideEffects;
import org.aion.zero.impl.db.AionRepositoryCache;
import org.aion.zero.impl.db.AionRepositoryImpl;
import org.aion.zero.impl.db.ContractDetailsAion;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -23,12 +32,37 @@ public class BridgeControllerOwnerTest {

private static final Address CONTRACT_ADDR =
new Address(HashUtil.h256("contractAddress".getBytes()));
private static final Address OWNER_ADDR =
new Address(HashUtil.h256("ownerAddress".getBytes()));
private static final Address OWNER_ADDR = new Address(HashUtil.h256("ownerAddress".getBytes()));

@Before
public void beforeEach() {
DummyRepo repo = new DummyRepo();
RepositoryConfig repoConfig =
new RepositoryConfig() {
@Override
public String getDbPath() {
return "";
}

@Override
public PruneConfig getPruneConfig() {
return new CfgPrune(false);
}

@Override
public ContractDetails contractDetailsImpl() {
return ContractDetailsAion.createForTesting(0, 1000000).getDetails();
}

@Override
public Properties getDatabaseConfig(String db_name) {
Properties props = new Properties();
props.setProperty(DatabaseFactory.Props.DB_TYPE, DBVendor.MOCKDB.toValue());
props.setProperty(DatabaseFactory.Props.ENABLE_HEAP_CACHE, "false");
return props;
}
};
AionRepositoryCache repo =
new AionRepositoryCache(AionRepositoryImpl.createForTesting(repoConfig));
this.connector = new BridgeStorageConnector(repo, CONTRACT_ADDR);

ExecutionContext context = dummyContext();
Expand Down
Loading

0 comments on commit d7e0866

Please sign in to comment.