-
Notifications
You must be signed in to change notification settings - Fork 30
Add TestKit [ECR-3049] #819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
ad8dd51
faf6e64
ff08c65
2059e19
018604b
1616b08
1e7fa23
2087fc3
f646912
cb4a3f0
74d67c4
2db08d0
0c47320
3fcd890
01cd8d4
4aa914f
38f2697
2231a78
88cbab6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.exonum.binding</groupId> | ||
<artifactId>exonum-java-binding-parent</artifactId> | ||
<version>0.6.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>exonum-testkit</artifactId> | ||
<version>0.6.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Exonum TestKit</name> | ||
<url>https://exonum.com/doc/version/latest/get-started/test-service/</url> | ||
|
||
<properties> | ||
<ejb-core.nativeLibPath>${project.parent.basedir}/core/rust/target/debug | ||
</ejb-core.nativeLibPath> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.exonum.binding</groupId> | ||
<artifactId>exonum-java-binding-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<argLine> | ||
${jacoco.args} | ||
-Djava.library.path=${ejb-core.nativeLibPath} | ||
${java.vm.assertionFlag} | ||
</argLine> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2019 The Exonum Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.exonum.binding.testkit; | ||
|
||
import com.exonum.binding.common.crypto.KeyPair; | ||
import java.util.OptionalInt; | ||
|
||
/** | ||
* Context of the TestKit emulated node. | ||
*/ | ||
public class EmulatedNode { | ||
|
||
private final OptionalInt validatorId; | ||
private final KeyPair serviceKeyPair; | ||
private final KeyPair consensusKeyPair; | ||
|
||
public EmulatedNode(int validatorId, KeyPair serviceKeyPair, KeyPair consensusKeyPair) { | ||
this.validatorId = validatorId >= 0 | ||
? OptionalInt.of(validatorId) | ||
: OptionalInt.empty(); | ||
this.serviceKeyPair = serviceKeyPair; | ||
this.consensusKeyPair = consensusKeyPair; | ||
} | ||
|
||
/** | ||
* Returns a node type - either {@link EmulatedNodeType.VALIDATOR} or {@link EmulatedNodeType.AUDITOR}. | ||
*/ | ||
public EmulatedNodeType getNodeType() { | ||
return validatorId.isPresent() ? EmulatedNodeType.VALIDATOR : EmulatedNodeType.AUDITOR; | ||
} | ||
|
||
/** | ||
* Returns a validator id if this node is a validator or {@link OptionalInt.EMPTY} is this is a validator node. | ||
|
||
*/ | ||
public OptionalInt getValidatorId() { | ||
return validatorId; | ||
} | ||
|
||
/** | ||
* Returns a service key pair of this node. | ||
|
||
*/ | ||
public KeyPair getServiceKeyPair() { | ||
return serviceKeyPair; | ||
} | ||
|
||
/** | ||
* Returns a consensus key pair of this node. | ||
|
||
*/ | ||
public KeyPair getConsensusKeyPair() { | ||
return consensusKeyPair; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2019 The Exonum Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.exonum.binding.testkit; | ||
|
||
/** | ||
* Type of the TestKit emulated node. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
public enum EmulatedNodeType { | ||
VALIDATOR, | ||
AUDITOR | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2019 The Exonum Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.exonum.binding.testkit; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
public class FakeTimeProvider implements TimeProvider { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. javadoc is missing. Please describe the purpose of this class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or is it decided that it is better to add this just as a placeholder and implement in a separate PR, as originally planned? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, sorry for half-introducing classes from other tasks - I wanted native methods signatures to be ready for native tasks, so created these classes as placeholders There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep them as placeholders to avoid redundant work then. |
||
|
||
public FakeTimeProvider create(ZonedDateTime time) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public void setTime(ZonedDateTime time) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public void addTime(ZonedDateTime time) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ZonedDateTime getTime() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since #818 it must be slightly different, @vitvakatu can advise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay, as we don't have tests with release mode at the moment