Conversation
# Conflicts: # src/main/java/com/casper/sdk/model/status/StatusData.java
| final ObjectNode treeNode = p.readValueAsTree(); | ||
| final Iterator<String> stringIterator = treeNode.fieldNames(); | ||
| final String next = stringIterator.next(); | ||
| if (next.equals(Session.class.getSimpleName())) { |
There was a problem hiding this comment.
Always perform if checks with the constant just in case the next value is null
| final Iterator<String> stringIterator = treeNode.fieldNames(); | ||
| final String next = stringIterator.next(); | ||
| if (next.equals(Session.class.getSimpleName())) { | ||
| return new Session("Session", treeNode.get(next).get("module_bytes").asText().getBytes(), |
There was a problem hiding this comment.
Doesn't the string value need a hex decode?
| return Stored.class; | ||
| } else { | ||
| throw new NoSuchTypeException("No such type: " + classType); | ||
| private TransactionRuntime getTransactionRuntime(final String runtime){ |
There was a problem hiding this comment.
This should live in the TransactionRuntime and be named fromJsonName or similar. May be better to have a jsonValue field in the Enum rather than an annotation now we are doing this by hand.
| } | ||
| } | ||
|
|
||
| private static String getTransactionRuntime(final TransactionRuntime value) throws NoSuchFieldException { |
There was a problem hiding this comment.
Move to TransactionRuntime class and change to astJsonName or similar
| final Session session = (Session) sessionTransactionTarget; | ||
|
|
||
| assertThat(session.getRuntime().name(), is(TransactionRuntime.VM_CASPER_V2.name())); | ||
| assertThat(session.getTarget(), is("Session")); |
There was a problem hiding this comment.
You need to test the module_bytes too
| final Session session = (Session) sessionTransactionTarget; | ||
|
|
||
| assertThat(session.getRuntime().name(), is(TransactionRuntime.VM_CASPER_V2.name())); | ||
| assertThat(session.getTarget(), is("Session")); |
There was a problem hiding this comment.
You need to test the module_bytes too
| @JsonTypeName("Session") | ||
| public class Session implements TransactionTarget { | ||
|
|
||
| @JsonValue |
There was a problem hiding this comment.
What is the target field used for? The class name is the name of the target.
| /** | ||
| * @author carl@stormeye.co.uk | ||
| */ | ||
| public class TransactionTargetTest { |
There was a problem hiding this comment.
Would be good to round trip JSON on the transaction targets
| ``` | ||
|
|
||
| ### | ||
|
|
There was a problem hiding this comment.
Why are there empty lines herer?
| } else if (value instanceof Native) { | ||
| gen.writeString("Native"); | ||
| } else if (value instanceof Stored){ | ||
| //TODO |
There was a problem hiding this comment.
Throw an exception here with the message "Stored is not yet Implemented"
| return t; | ||
| } | ||
| } | ||
| throw new NoSuchTypeException(); |
There was a problem hiding this comment.
Pass in the type name as part of the exception message.
| } | ||
|
|
||
| @Test | ||
| void chainPutContractCep18() throws IOException, ValueSerializationException, URISyntaxException, TimeoutException { |
There was a problem hiding this comment.
Should really mock this once you have a valid response from the node
No description provided.