public class NeoExpressTestContainer extends org.testcontainers.containers.GenericContainer<NeoExpressTestContainer> implements TestBlockchain
TestBlockchain.GenesisAccount| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONTAINER_WORKDIR |
static java.lang.String |
DEFAULT_NEOXP_CONFIG |
static java.lang.String |
NEOXP_CONFIG_DEST |
| Constructor and Description |
|---|
NeoExpressTestContainer(java.lang.String... resources)
Creates a new instance of a docker container running a neo-express private network.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
createAccount()
Creates a new account on the neo-express instance.
|
java.lang.String |
enableOracle()
Enables the oracle service on the neo-express instance
|
java.lang.String |
execCommand(java.lang.String... commandParts)
Executes the given command on the neo-express instance.
|
java.lang.String |
fastForward(int n)
Fast-forwards the blockchain state by
n blocks. |
java.lang.String |
fastForward(int seconds,
int n)
Mints
n blocks with the last block being seconds in the future. |
java.lang.String |
getAccount(java.lang.String address)
Gets the private key corresponding to the given address.
|
TestBlockchain.GenesisAccount |
getGenesisAccount()
Gets the genesis account this blockchain is based on.
|
java.lang.String |
getNodeUrl()
Gets the URL of the neo-express node running in the container.
|
java.lang.String |
halt()
Stops the neo-express instance.
|
java.lang.String |
resume()
Runs neo-express if it was stopped before.
|
void |
start()
Starts the blockchain, i.e., the process that includes the blockchain.
|
NeoExpressTestContainer |
withBatchFile(java.lang.String batchFile)
Adds the given batch file to the test container and executes it before the neo-express instance is started.
|
NeoExpressTestContainer |
withCheckpoint(java.lang.String checkpointFile)
Adds the given checkpoint file to the test container and executes it before the neo-express instance is started.
|
NeoExpressTestContainer |
withConfigFile(java.lang.String configFile)
Adds the given neo-express config file to the test container.
|
NeoExpressTestContainer |
withNefAndManifestFiles(java.lang.String nefFile,
java.lang.String manifestFile)
Adds the given NEF and manifest files to the test container.
|
NeoExpressTestContainer |
withSecondsPerBlock(int secondsPerBlock)
Sets the given block time.
|
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryclone, finalize, getClass, notify, notifyAll, wait, wait, waitstopaddFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindcopyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningpublic static final java.lang.String DEFAULT_NEOXP_CONFIG
public static final java.lang.String CONTAINER_WORKDIR
public static final java.lang.String NEOXP_CONFIG_DEST
public NeoExpressTestContainer(java.lang.String... resources)
resources - the names of the files that should be copied into the container. For each file you need to
set a source and a destination (in the container) path consecutively.public void start()
TestBlockchainstart in interface TestBlockchainstart in interface org.testcontainers.lifecycle.Startablestart in class org.testcontainers.containers.GenericContainer<NeoExpressTestContainer>public NeoExpressTestContainer withSecondsPerBlock(int secondsPerBlock)
withSecondsPerBlock in interface TestBlockchainsecondsPerBlock - the block time.public NeoExpressTestContainer withBatchFile(java.lang.String batchFile)
The batch file must be located in the resources directory.
withBatchFile in interface TestBlockchainbatchFile - the batch file name.public NeoExpressTestContainer withCheckpoint(java.lang.String checkpointFile)
The file must be located in the resources directory.
If both a batch and a checkpoint file is added, the checkpoint is first applied.
withCheckpoint in interface TestBlockchaincheckpointFile - the checkpoint file name.public NeoExpressTestContainer withConfigFile(java.lang.String configFile)
The file must be located in the resources directory.
withConfigFile in interface TestBlockchainconfigFile - the config file name.public NeoExpressTestContainer withNefAndManifestFiles(java.lang.String nefFile, java.lang.String manifestFile)
neoxp contract deploy.
The files must be located in the resources directory.
The copied files in the container will have the same name as the given sources.
nefFile - the NEF file name.manifestFile - the manifest file name.public java.lang.String getNodeUrl()
getNodeUrl in interface TestBlockchainpublic java.lang.String resume()
throws java.lang.Exception
resume in interface TestBlockchainjava.lang.Exception - if an error occurs while trying to start neo-express.public java.lang.String halt()
throws java.lang.Exception
halt in interface TestBlockchainjava.lang.Exception - if an error occurs when trying to stop neo-express.public java.lang.String createAccount()
throws java.lang.Exception
createAccount in interface TestBlockchainjava.lang.Exception - if an error occurs when trying to create the account.public java.lang.String enableOracle()
throws java.lang.Exception
enableOracle in interface TestBlockchainjava.lang.Exception - if the execution failed.public java.lang.String fastForward(int n)
throws java.lang.Exception
n blocks. I.e., mints n empty blocks. The block
timestamps are according to the current system time.fastForward in interface TestBlockchainn - the number of blocks to mint.java.lang.Exception - if the execution failed.public java.lang.String fastForward(int seconds,
int n)
throws java.lang.Exception
n blocks with the last block being seconds in the future.fastForward in interface TestBlockchainseconds - the time delta in seconds from now.n - the number of blocks to mint.java.lang.Exception - if the execution failed.public java.lang.String execCommand(java.lang.String... commandParts)
throws java.lang.Exception
The command has to be provided in its separate parts, e.g., "neoxp", "contract", "run", "NeoToken",
"balanceOf", "NM7Aky765FG8NhhwtxjXRx7jEL1cnw7PBP", "--account genesis"
execCommand in interface TestBlockchaincommandParts - the command separated into its parts.java.lang.Exception - if the execution failed.public java.lang.String getAccount(java.lang.String address)
throws java.io.IOException
TestBlockchainThis is not meant to be used for multi-sig accounts.
getAccount in interface TestBlockchainaddress - the account's address.java.io.IOExceptionpublic TestBlockchain.GenesisAccount getGenesisAccount() throws java.io.IOException
TestBlockchainThis is for test blockchains that provide control over the genesis account. The genesis account owns all NEO and GAS tokens starting from the first block.
getGenesisAccount in interface TestBlockchainjava.io.IOException