Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class PolkadotHttpClientSpec extends Specification {
' "stateRoot": "0x0984f5c13d7d271467332697fa5fc191539c1441f5ca1b234618ff25638b7d66"' +
' }' +
' },' +
' "justification": null' +
' "justifications": []' +
' },' +
' "id": 0' +
'}'
Expand All @@ -140,7 +140,7 @@ class PolkadotHttpClientSpec extends Specification {
.withBody('{"jsonrpc":"2.0","id":0,"method":"chain_getBlock","params":["0x9130103f8fbca52a79042211383946b39e6269b6ab49bc08035c9893d782c1bb"]}')
)

act.justification == null
act.justifications.length == 0
act.block != null
with(act.block) {
header.number == 0x401a1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package io.emeraldpay.polkaj.json;

import java.util.Arrays;
import java.util.Objects;

public class BlockResponseJson {

private BlockJson block;
private Object justification;
private Object[] justifications;

public BlockResponseJson() {
}
Expand All @@ -22,12 +23,12 @@ public void setBlock(BlockJson block) {
this.block = block;
}

public Object getJustification() {
return justification;
public Object[] getJustifications() {
return justifications;
}

public void setJustification(Object justification) {
this.justification = justification;
public void setJustifications(Object[] justifications) {
this.justifications = justifications;
}

@Override
Expand All @@ -36,11 +37,13 @@ public boolean equals(Object o) {
if (!(o instanceof BlockResponseJson)) return false;
BlockResponseJson that = (BlockResponseJson) o;
return Objects.equals(block, that.block) &&
Objects.equals(justification, that.justification);
Arrays.equals(justifications, that.justifications);
}

@Override
public int hashCode() {
return Objects.hash(block, justification);
int result = Objects.hash(block);
result = 31 * result + Arrays.hashCode(justifications);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BlockResponseJsonSpec extends Specification {
then:
act != null
act.block != null
act.justification == null
act.justifications.length == 0
with(act.block) {
extrinsics.size() == 3
with(header) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"stateRoot": "0x0984f5c13d7d271467332697fa5fc191539c1441f5ca1b234618ff25638b7d66"
}
},
"justification": null
"justifications": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class AccountInfo {
private Long nonce;
private Long consumers;
private Long providers;
private Long sufficients;
private AccountData data;

public Long getNonce() {
Expand All @@ -33,6 +34,14 @@ public void setProviders(Long providers) {
this.providers = providers;
}

public Long getSufficients() {
return sufficients;
}

public void setSufficients(Long sufficients) {
this.sufficients = sufficients;
}

public AccountData getData() {
return data;
}
Expand All @@ -49,11 +58,12 @@ public boolean equals(Object o) {
return Objects.equals(nonce, that.nonce) &&
Objects.equals(consumers, that.consumers) &&
Objects.equals(providers, that.providers) &&
Objects.equals(sufficients, that.sufficients) &&
Objects.equals(data, that.data);
}

@Override
public int hashCode() {
return Objects.hash(nonce, consumers, providers, data);
return Objects.hash(nonce, consumers, providers, sufficients, data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public AccountInfo read(ScaleCodecReader rdr) {
result.setNonce(rdr.readUint32());
result.setConsumers(rdr.readUint32());
result.setProviders(rdr.readUint32());
result.setSufficients(rdr.readUint32());
result.setData(rdr.read(new AccountDataReader()));
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ class AccountInfoReaderSpec extends Specification {

def "Read value"() {
setup:
def value = Hex.decodeHex("110000000300000004000000f70af5f6f3c843050000000000000000000000000000000000000000000000000000c52ebca2b10000000000000000000000c52ebca2b1000000000000000000")
def value = Hex.decodeHex("11000000030000000400000005000000f70af5f6f3c843050000000000000000000000000000000000000000000000000000c52ebca2b10000000000000000000000c52ebca2b1000000000000000000")
when:
def act = new ScaleCodecReader(value).read(reader)
then:
act != null
act.nonce == 17
act.consumers == 3
act.providers == 4
act.sufficients == 5
with(act.data) {
free == DotAmount.fromPlancks(379367743775116023)
reserved == DotAmount.ZERO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ class AccountRequestsSpec extends Specification {
def "Decode balance response"() {
setup:
def req = AccountRequests.balanceOf(Address.from("1WG3jyNqniQMRZGQUc7QD2kVLT8hkRPGMSqAb5XYQM1UDxN"))
def result = ByteData.from("0x110000000300000004000000f70af5f6f3c843050000000000000000000000000000000000000000000000000000c52ebca2b10000000000000000000000c52ebca2b1000000000000000000")
def result = ByteData.from("0x11000000030000000400000005000000f70af5f6f3c843050000000000000000000000000000000000000000000000000000c52ebca2b10000000000000000000000c52ebca2b1000000000000000000")
when:
def act = req.apply(result)
then:
act.nonce == 17
act.consumers == 3
act.providers == 4
act.sufficients == 5
with(act.data) {
free == DotAmount.fromPlancks(379367743775116023)
reserved == DotAmount.ZERO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ExtrinsicContextAutoBuilderSpec extends Specification {
StandardCommands.getInstance().stateGetStorage(requestAccount.encodeRequest())
) >> CompletableFuture.completedFuture(
// 1,000,000.00 Dot, nonce = 1
ByteData.from("0x01000000000000000000000019e4759db3b6e00d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
ByteData.from("0x0100000000000000000000000000000019e4759db3b6e00d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
)
1 * execute(
StandardCommands.getInstance().getBlockHash(0)
Expand Down