test_sdk1 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +1 -0
- data/LICENSE +201 -0
- data/README.md +147 -0
- data/SECURITY.md +12 -0
- data/lib/crypto/00_asymmetric_key.rb +95 -0
- data/lib/crypto/01_ed25519.rb +67 -0
- data/lib/crypto/asymmetric_key.rb +87 -0
- data/lib/crypto/ed25519_key.rb +44 -0
- data/lib/crypto/key_pair.rb +40 -0
- data/lib/crypto/keys.rb +7 -0
- data/lib/crypto/secp256k1_key.rb +0 -0
- data/lib/crypto/test_ed25519_key.rb +44 -0
- data/lib/entity/account.rb +45 -0
- data/lib/entity/action_thresholds.rb +25 -0
- data/lib/entity/associated_key.rb +24 -0
- data/lib/entity/auction_state.rb +36 -0
- data/lib/entity/bid.rb +24 -0
- data/lib/entity/bid_info.rb +51 -0
- data/lib/entity/contract.rb +47 -0
- data/lib/entity/contract_package.rb +41 -0
- data/lib/entity/contract_version.rb +33 -0
- data/lib/entity/delegator.rb +37 -0
- data/lib/entity/deploy.rb +44 -0
- data/lib/entity/deploy_approval.rb +24 -0
- data/lib/entity/deploy_executable.rb +162 -0
- data/lib/entity/deploy_executable_item_internal.rb +26 -0
- data/lib/entity/deploy_executable_transfer.rb +50 -0
- data/lib/entity/deploy_hash.rb +16 -0
- data/lib/entity/deploy_header.rb +60 -0
- data/lib/entity/deploy_info.rb +44 -0
- data/lib/entity/deploy_named_argument.rb +19 -0
- data/lib/entity/deploy_transfer.rb +10 -0
- data/lib/entity/disabled_version.rb +26 -0
- data/lib/entity/era_info.rb +18 -0
- data/lib/entity/era_summary.rb +44 -0
- data/lib/entity/era_validator.rb +23 -0
- data/lib/entity/executable_deploy_item.rb +11 -0
- data/lib/entity/group.rb +25 -0
- data/lib/entity/module_bytes.rb +50 -0
- data/lib/entity/peer.rb +25 -0
- data/lib/entity/seigniorage_allocation.rb +18 -0
- data/lib/entity/stored_contract_by_hash.rb +50 -0
- data/lib/entity/stored_contract_by_name.rb +50 -0
- data/lib/entity/stored_value.rb +57 -0
- data/lib/entity/stored_versioned_contract_by_hash.rb +61 -0
- data/lib/entity/stored_versioned_contract_by_name.rb +61 -0
- data/lib/entity/transfer.rb +65 -0
- data/lib/entity/validator_weight.rb +23 -0
- data/lib/entity/vesting_schedule.rb +22 -0
- data/lib/include.rb +18 -0
- data/lib/rpc/rpc.rb +227 -0
- data/lib/rpc/rpc_client.rb +233 -0
- data/lib/rpc/rpc_error.rb +79 -0
- data/lib/serialization/cl_type_serializer.rb +76 -0
- data/lib/serialization/cl_value_bytes_parsers.rb +498 -0
- data/lib/serialization/cl_value_serializer.rb +259 -0
- data/lib/serialization/deploy_approval_serializer.rb +15 -0
- data/lib/serialization/deploy_executable_serializer.rb +27 -0
- data/lib/serialization/deploy_header_serializer.rb +49 -0
- data/lib/serialization/deploy_named_arg_serializer.rb +19 -0
- data/lib/serialization/deploy_serializer.rb +268 -0
- data/lib/serialization/test.rb +431 -0
- data/lib/test_sdk1.rb +289 -0
- data/lib/types/cl_account_hash.rb +24 -0
- data/lib/types/cl_account_hash_type.rb +22 -0
- data/lib/types/cl_any.rb +25 -0
- data/lib/types/cl_any_type.rb +22 -0
- data/lib/types/cl_bool.rb +32 -0
- data/lib/types/cl_bool_type.rb +35 -0
- data/lib/types/cl_byte_array.rb +25 -0
- data/lib/types/cl_byte_array_type.rb +27 -0
- data/lib/types/cl_i32.rb +26 -0
- data/lib/types/cl_i32_type.rb +26 -0
- data/lib/types/cl_i64.rb +26 -0
- data/lib/types/cl_i64_type.rb +27 -0
- data/lib/types/cl_key.rb +39 -0
- data/lib/types/cl_key_type.rb +27 -0
- data/lib/types/cl_list.rb +25 -0
- data/lib/types/cl_list_type.rb +26 -0
- data/lib/types/cl_map.rb +25 -0
- data/lib/types/cl_map_type.rb +26 -0
- data/lib/types/cl_option.rb +33 -0
- data/lib/types/cl_option_type.rb +52 -0
- data/lib/types/cl_public_key.rb +152 -0
- data/lib/types/cl_public_key_type.rb +26 -0
- data/lib/types/cl_result.rb +25 -0
- data/lib/types/cl_result_type.rb +26 -0
- data/lib/types/cl_string.rb +39 -0
- data/lib/types/cl_string_type.rb +32 -0
- data/lib/types/cl_tuple.rb +151 -0
- data/lib/types/cl_tuple_type.rb +108 -0
- data/lib/types/cl_type.rb +94 -0
- data/lib/types/cl_type_tag.rb +51 -0
- data/lib/types/cl_u128.rb +26 -0
- data/lib/types/cl_u128_type.rb +26 -0
- data/lib/types/cl_u256.rb +26 -0
- data/lib/types/cl_u256_type.rb +26 -0
- data/lib/types/cl_u32.rb +26 -0
- data/lib/types/cl_u32_type.rb +26 -0
- data/lib/types/cl_u512.rb +26 -0
- data/lib/types/cl_u512_type.rb +26 -0
- data/lib/types/cl_u64.rb +26 -0
- data/lib/types/cl_u64_type.rb +27 -0
- data/lib/types/cl_u8.rb +26 -0
- data/lib/types/cl_u8_type.rb +26 -0
- data/lib/types/cl_unit.rb +38 -0
- data/lib/types/cl_unit_type.rb +22 -0
- data/lib/types/cl_uref.rb +120 -0
- data/lib/types/cl_uref_type.rb +46 -0
- data/lib/types/cl_value.rb +10 -0
- data/lib/types/constants.rb +50 -0
- data/lib/types/error.rb +7 -0
- data/lib/utils/base_16.rb +18 -0
- data/lib/utils/byte_utils.rb +107 -0
- data/lib/utils/find_byte_parser_by_cl_type.rb +53 -0
- data/lib/utils/hash_utils.rb +19 -0
- data/lib/utils/hex_utils.rb +12 -0
- data/lib/utils/time_utils.rb +85 -0
- data/lib/utils/utils.rb +2 -0
- data/lib/version.rb +3 -0
- data/spec/a_spec.rb +697 -0
- data/spec/byte_utils_spec.rb +72 -0
- data/spec/cl_public_spec.rb +169 -0
- data/spec/cl_types_spec.rb +715 -0
- data/spec/cl_value_serializer_spec.rb +140 -0
- data/spec/client_spec.rb +25 -0
- data/spec/crypto_spec.rb +42 -0
- data/spec/deploy_approval_serializer_spec.rb +26 -0
- data/spec/deploy_executable_serializer_spec.rb +0 -0
- data/spec/deploy_header_serializer_spec.rb +21 -0
- data/spec/deploy_named_arg_serializer_spec.rb +49 -0
- data/spec/deploy_serializer_spec.rb +77 -0
- data/spec/deploy_serializer_test_spec.rb +225 -0
- data/spec/mainnet_spec.rb +452 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/string_spec.rb +68 -0
- data/spec/testnet_spec.rb +498 -0
- data/spec/time_utils_spec.rb +87 -0
- metadata +198 -0
@@ -0,0 +1,140 @@
|
|
1
|
+
require_relative '../lib/serialization/cl_value_serializer.rb'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe CLValueSerializer do
|
5
|
+
let (:serializer) { CLValueSerializer.new }
|
6
|
+
|
7
|
+
describe "CLBool Value Serializer" do
|
8
|
+
let (:bool1) { CLBool.new(false) }
|
9
|
+
let (:bool2) { CLBool.new(true) }
|
10
|
+
|
11
|
+
it "should serialize CLBool values" do
|
12
|
+
expect(serializer.to_bytes(bool1)).to eq("010000000000")
|
13
|
+
expect(serializer.to_bytes(bool2)).to eq("010000000100")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "CLi32 Value Serializer" do
|
18
|
+
let (:i32_1) { CLi32.new(-10) }
|
19
|
+
let (:i32_2) { CLi32.new(10) }
|
20
|
+
|
21
|
+
it "should serialize CLi32 values" do
|
22
|
+
expect(serializer.to_bytes(i32_1)).to eq("04000000f6ffffff01")
|
23
|
+
expect(serializer.to_bytes(i32_2)).to eq("040000000a00000001")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "CLi64 Value Serializer" do
|
28
|
+
let (:i64_1) { CLi64.new(-16) }
|
29
|
+
let (:i64_2) { CLi64.new(16) }
|
30
|
+
|
31
|
+
it "should serialize CLi64 values" do
|
32
|
+
expect(serializer.to_bytes(i64_1)).to eq("08000000f0ffffffffffffff02")
|
33
|
+
expect(serializer.to_bytes(i64_2)).to eq("08000000100000000000000002")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "CLu8 Value Serializer" do
|
38
|
+
let (:u8_1) { CLu8.new(0x00) }
|
39
|
+
let (:u8_2) { CLu8.new(0x7F) }
|
40
|
+
|
41
|
+
it "should serialize CLu8 values" do
|
42
|
+
expect(serializer.to_bytes(u8_1)).to eq("010000000003")
|
43
|
+
expect(serializer.to_bytes(u8_2)).to eq("010000007f03")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "CLu32 Value Serializer" do
|
48
|
+
|
49
|
+
# MAX_U32 = 2.pow(32) - 1
|
50
|
+
# MIN_U32 = 0
|
51
|
+
let (:u32_1) { CLu32.new(MAX_U32) }
|
52
|
+
let (:u32_2) { CLu32.new(MIN_U32) }
|
53
|
+
|
54
|
+
it "should serialize CLu32 values" do
|
55
|
+
expect(serializer.to_bytes(u32_1)).to eq("04000000ffffffff04")
|
56
|
+
expect(serializer.to_bytes(u32_2)).to eq("040000000000000004")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "CLu64 Value Serializer" do
|
61
|
+
# MAX_U64 = 2.pow(64) - 1
|
62
|
+
# MIN_U64 = 0
|
63
|
+
let (:u64_1) { CLu64.new(MAX_U64) }
|
64
|
+
let (:u64_2) { CLu64.new(1) }
|
65
|
+
|
66
|
+
it "should serialize CLu64 values" do
|
67
|
+
expect(serializer.to_bytes(u64_1)).to eq("08000000ffffffffffffffff05")
|
68
|
+
expect(serializer.to_bytes(u64_2)).to eq("08000000010000000000000005")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "CLString Value Serializer" do
|
73
|
+
let (:str1) { CLString.new("Hello, Casper!") }
|
74
|
+
it "should serialize CLString values" do
|
75
|
+
expect(serializer.to_bytes(str1)).to eq("120000000e00000048656c6c6f2c20436173706572210a")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "CLURef Value Serializer" do
|
80
|
+
let (:uref) { "uref-000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f-007" }
|
81
|
+
let (:clvalue) { CLURef.new(uref) }
|
82
|
+
it "should serialize CLURef values" do
|
83
|
+
expect(serializer.to_bytes(clvalue)).to eq("21000000000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f070c")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "CLPublicKey Value Serializer" do
|
88
|
+
let (:pub_key_hex_ed25519) { "010af5a943bacd2a8e91792eb4e9a25e32d536ab103372f57f89ebcadfc59820d1" }
|
89
|
+
let (:pub_raw_ed25519) { [10, 245, 169, 67, 186, 205, 42, 142,
|
90
|
+
145, 121, 46, 180, 233, 162,94, 50,
|
91
|
+
213, 54, 171, 16, 51, 114, 245, 127, 137,
|
92
|
+
235, 202, 223, 197, 152, 32, 209] }
|
93
|
+
let (:clvalue) { CLPublicKey.new(pub_raw_ed25519, CLPublicKeyTag[:ED25519]) }
|
94
|
+
it "should serialize CLPublicKey values" do
|
95
|
+
expect(serializer.to_bytes(clvalue)).to eq("21000000010af5a943bacd2a8e91792eb4e9a25e32d536ab103372f57f89ebcadfc59820d116")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe CLTuple do
|
100
|
+
let (:bool) { CLBool.new(true) }
|
101
|
+
let (:u32_1) { CLu32.new(17) }
|
102
|
+
let (:u32_2) { CLu32.new(127) }
|
103
|
+
let (:str) { CLString.new("ABCDE") }
|
104
|
+
|
105
|
+
describe CLTuple1 do
|
106
|
+
let (:tuple1) { CLTuple1.new([bool]) }
|
107
|
+
let (:tuples) { [CLTuple1.new([bool]), CLTuple1.new([u32_1]), CLTuple1.new([str])] }
|
108
|
+
it "should serialize CLTuple1" do
|
109
|
+
expect(serializer.to_bytes(tuple1)).to eq("01000000011200")
|
110
|
+
expect(serializer.to_bytes(tuples[0])).to eq("01000000011200")
|
111
|
+
expect(serializer.to_bytes(tuples[1])).to eq("04000000110000001204")
|
112
|
+
expect(serializer.to_bytes(tuples[2])).to eq("09000000050000004142434445120a")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe CLTuple2 do
|
117
|
+
let (:tuples) { [CLTuple2.new([u32_1, u32_2]), CLTuple2.new([u32_2, str])] }
|
118
|
+
it "should serialize CLTuple2" do
|
119
|
+
expect(serializer.to_bytes(tuples[0])).to eq("08000000110000007f000000130404")
|
120
|
+
expect(serializer.to_bytes(tuples[1])).to eq("0d0000007f00000005000000414243444513040a")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe CLTuple3 do
|
125
|
+
let (:tuples) { [CLTuple3.new([u32_1, u32_2, u32_1]), CLTuple3.new([u32_2, str, u32_2])] }
|
126
|
+
it "should serialize CLTuple3" do
|
127
|
+
expect(serializer.to_bytes(tuples[0])).to eq("0c000000110000007f0000001100000014040404")
|
128
|
+
expect(serializer.to_bytes(tuples[1])).to eq("110000007f0000000500000041424344457f00000014040a04")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "CLUnit Value Serializer" do
|
134
|
+
let(:unit) {CLUnit.new()}
|
135
|
+
it "should serialize CLUnit values" do
|
136
|
+
puts serializer.to_bytes(unit)
|
137
|
+
expect(serializer.to_bytes(unit)).to eql("0000000009")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# client_spec.rb
|
2
|
+
# require './lib/casper_network.rb'
|
3
|
+
|
4
|
+
# describe CasperClient do
|
5
|
+
# client1 = CasperClient.new("185.246.84.43")
|
6
|
+
# # Test info_get_peers()
|
7
|
+
# describe "#info_get_peers" do
|
8
|
+
# it "returns peers array." do
|
9
|
+
# # Check whether ıt is an array or not
|
10
|
+
# expect(client1.info_get_peers).to be_an(Array)
|
11
|
+
# # Check the length of the peers array
|
12
|
+
# expect(client1.info_get_peers.length).to be > 0
|
13
|
+
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
# # Test chain_get_StateRootHash()
|
17
|
+
# describe "#chain_get_StateRootHash" do
|
18
|
+
# it "returns current state_root_hash." do
|
19
|
+
# # Check whether its type is string or not
|
20
|
+
# expect(client1.chain_get_StateRootHash).to be_an(String)
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
|
24
|
+
|
25
|
+
# end
|
data/spec/crypto_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# require_relative '../lib/crypto/asymmetric_key.rb'
|
2
|
+
# require_relative '../lib/crypto/ed25519_key.rb'
|
3
|
+
# require_relative '../lib/types/cl_public_key.rb'
|
4
|
+
|
5
|
+
# $pub_raw_ed25519 = [
|
6
|
+
# 10, 245, 169, 67, 186, 205, 42, 142,
|
7
|
+
# 145, 121, 46, 180, 233, 162, 94, 50,
|
8
|
+
# 213, 54, 171, 16, 51, 114, 245, 127,
|
9
|
+
# 137, 235, 202, 223, 197, 152, 32, 209
|
10
|
+
# ]
|
11
|
+
# $private_key = [
|
12
|
+
# 233, 167, 59, 188, 240, 81, 151, 35, 145, 66, 150,
|
13
|
+
# 154, 239, 229, 16, 106, 66, 19, 86, 89, 193, 209,
|
14
|
+
# 176, 51, 125, 113, 212, 6, 27, 193, 145, 49, 201,
|
15
|
+
# 121, 63, 103, 146, 81, 130, 70, 221, 206, 116, 15,
|
16
|
+
# 62, 0, 1, 142, 227, 69, 220, 130, 20, 162, 253,
|
17
|
+
# 39, 171, 238, 197, 211, 17, 155, 253, 177
|
18
|
+
# ]
|
19
|
+
|
20
|
+
# $pub_raw_secp256K1 = [
|
21
|
+
# 74, 231, 213, 182, 107, 47, 208, 246,
|
22
|
+
# 111, 176, 239, 204, 238, 203, 103, 59,
|
23
|
+
# 55, 98, 89, 91, 48, 174, 28, 172, 72,
|
24
|
+
# 174, 143, 9, 211, 76, 149, 46, 228
|
25
|
+
# ]
|
26
|
+
# describe Ed25519Key do
|
27
|
+
# let(:public_key) {CLPublicKey.new($pub_raw_ed25519, 1)}
|
28
|
+
# let(:ed25519) {Ed25519Key.new(public_key, $private_key)}
|
29
|
+
# it "print raw_public_key" do
|
30
|
+
# # p public_key
|
31
|
+
# # p public_key.to_account_hash_byte_array
|
32
|
+
# # p public_key.to_account_hash_hex
|
33
|
+
|
34
|
+
# # p ed25519.account_hash
|
35
|
+
# # p ed25519.get_public_key
|
36
|
+
|
37
|
+
# # p ed25519.account_hex(ed25519.get_public_key)
|
38
|
+
# p ed25519.get_public_key_hex
|
39
|
+
# # p ed25519.account_hex
|
40
|
+
# p ed25519.account_hex(public_key)
|
41
|
+
# end
|
42
|
+
# end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../lib/serialization/deploy_approval_serializer.rb'
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe DeployApprovalSerializer do
|
5
|
+
|
6
|
+
it "should serialize DeployAproval" do
|
7
|
+
approvals = [
|
8
|
+
{
|
9
|
+
"signer": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c",
|
10
|
+
"signature": "012dbf03817a51794a8e19e0724884075e6d1fbec326b766ecfa6658b41f81290da85e23b24e88b1c8d9761185c961daee1adab0649912a6477bcd2e69bd91bd08"
|
11
|
+
}
|
12
|
+
]
|
13
|
+
expected_serialized_deploy_approvals = "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c012dbf03817a51794a8e19e0724884075e6d1fbec326b766ecfa6658b41f81290da85e23b24e88b1c8d9761185c961daee1adab0649912a6477bcd2e69bd91bd08"
|
14
|
+
|
15
|
+
for item in approvals do
|
16
|
+
result = ""
|
17
|
+
approval = Casper::Entity::DeployApproval.new(item)
|
18
|
+
|
19
|
+
deploy_approval_serializer = DeployApprovalSerializer.new
|
20
|
+
approval_serializer = deploy_approval_serializer.to_bytes(approval)
|
21
|
+
result << approval_serializer
|
22
|
+
end
|
23
|
+
expect(result).to eql(expected_serialized_deploy_approvals)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../lib/serialization/deploy_header_serializer.rb'
|
2
|
+
|
3
|
+
RSpec.describe DeployHeaderSerializer do
|
4
|
+
it "should serialize DeployHeader" do
|
5
|
+
header = {
|
6
|
+
"account": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c",
|
7
|
+
"timestamp": "2020-11-17T00:39:24.072Z",
|
8
|
+
"ttl": "1h",
|
9
|
+
"gas_price": 1,
|
10
|
+
"body_hash": "4811966d37fe5674a8af4001884ea0d9042d1c06668da0c963769c3a01ebd08f",
|
11
|
+
"dependencies": ["0101010101010101010101010101010101010101010101010101010101010101"],
|
12
|
+
"chain_name": "casper-example"
|
13
|
+
}
|
14
|
+
|
15
|
+
expected_serialized_deploy_header = "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900ca856a4d37501000080ee36000000000001000000000000004811966d37fe5674a8af4001884ea0d9042d1c06668da0c963769c3a01ebd08f0100000001010101010101010101010101010101010101010101010101010101010101010e0000006361737065722d6578616d706c65"
|
16
|
+
|
17
|
+
deploy_header = Casper::Entity::DeployHeader.new(header)
|
18
|
+
header_serializer = DeployHeaderSerializer.new
|
19
|
+
expect(header_serializer.to_bytes(deploy_header)).to eql(expected_serialized_deploy_header)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative '../lib/serialization/cl_value_serializer.rb'
|
2
|
+
require_relative '../lib/serialization/deploy_named_arg_serializer.rb'
|
3
|
+
|
4
|
+
|
5
|
+
describe DeployNamedArgSerializer do
|
6
|
+
let (:serializer) { DeployNamedArgSerializer.new }
|
7
|
+
|
8
|
+
describe "#to_bytes" do
|
9
|
+
|
10
|
+
context "when DeployNamedArg has CLu32 value" do
|
11
|
+
let (:arg) { Casper::Entity::DeployNamedArgument.new("casper-testnet", CLu32.new(17)) }
|
12
|
+
|
13
|
+
it "should serialize DeployNamedArg with CLu32 value" do
|
14
|
+
expect(serializer.to_bytes(arg)).to eq("0e0000006361737065722d746573746e6574040000001100000004")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when DeployNamedArg has CLString value" do
|
19
|
+
let (:arg) { Casper::Entity::DeployNamedArgument.new("casper-testnet", CLString.new("Hello, World!")) }
|
20
|
+
|
21
|
+
it "should serialize DeployNamedArg with CLString value" do
|
22
|
+
expect(serializer.to_bytes(arg)).to eq("0e0000006361737065722d746573746e6574110000000d00000048656c6c6f2c20576f726c64210a")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when DeployNamedArg has CLURef value" do
|
27
|
+
let (:uref) { CLURef.new("uref-000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f-007") }
|
28
|
+
let (:arg) { Casper::Entity::DeployNamedArgument.new("casper-testnet", uref)}
|
29
|
+
|
30
|
+
it "should serialize DeployNamedArg with CLURef value" do
|
31
|
+
expect(serializer.to_bytes(arg)).to eq("0e0000006361737065722d746573746e657421000000000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f070c")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when DeployNamedArg has CLPublicKey value" do
|
36
|
+
let (:pub_key_hex_ed25519) { "010af5a943bacd2a8e91792eb4e9a25e32d536ab103372f57f89ebcadfc59820d1" }
|
37
|
+
let (:pub_raw_ed25519) { [10, 245, 169, 67, 186, 205, 42, 142,
|
38
|
+
145, 121, 46, 180, 233, 162, 94, 50,
|
39
|
+
213, 54, 171, 16, 51, 114, 245, 127,
|
40
|
+
137, 235, 202, 223, 197, 152, 32, 209 ] }
|
41
|
+
let (:cl_public_key) { CLPublicKey.new(pub_raw_ed25519, CLPublicKeyTag[:ED25519]) }
|
42
|
+
let (:arg) { Casper::Entity::DeployNamedArgument.new("casper-testnet", cl_public_key) }
|
43
|
+
|
44
|
+
it "should serialize DeployNamedArg with CLPublicKey value" do
|
45
|
+
expect(serializer.to_bytes(arg)).to eq("0e0000006361737065722d746573746e657421000000010af5a943bacd2a8e91792eb4e9a25e32d536ab103372f57f89ebcadfc59820d116")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative '../lib/entity/deploy_named_argument.rb'
|
2
|
+
require_relative '../lib/serialization/deploy_named_arg_serializer.rb'
|
3
|
+
require_relative '../lib/entity/deploy_executable_item_internal.rb'
|
4
|
+
require_relative '../lib/entity/deploy_executable.rb'
|
5
|
+
require_relative '../lib/entity/stored_contract_by_hash.rb'
|
6
|
+
require_relative '../lib/entity/stored_contract_by_name.rb'
|
7
|
+
require_relative '../lib/entity/stored_versioned_contract_by_hash.rb'
|
8
|
+
require_relative '../lib/entity/stored_versioned_contract_by_name.rb'
|
9
|
+
require_relative '../lib/serialization/deploy_executable_serializer.rb'
|
10
|
+
require_relative '../lib/entity/deploy.rb'
|
11
|
+
require_relative '../lib/entity/deploy_hash.rb'
|
12
|
+
require_relative '../lib/entity/deploy_header.rb'
|
13
|
+
require_relative '../lib/entity/deploy_approval.rb'
|
14
|
+
require_relative '../lib/entity/deploy_info.rb'
|
15
|
+
require_relative '../lib/entity/deploy.rb'
|
16
|
+
require_relative '../lib/serialization/deploy_serializer.rb'
|
17
|
+
|
18
|
+
describe DeploySerializer do
|
19
|
+
let(:byte_utils) { Utils::ByteUtils }
|
20
|
+
let(:serializer) { DeploySerializer.new }
|
21
|
+
it "should serialize Deploy" do
|
22
|
+
serialized_deploy = "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900ca856a4d37501000080ee36000000000001000000000000004811966d37fe5674a8af4001884ea0d9042d1c06668da0c963769c3a01ebd08f0100000001010101010101010101010101010101010101010101010101010101010101010e0000006361737065722d6578616d706c6501da3c604f71e0e7df83ff1ab4ef15bb04de64ca02e3d2b78de6950e8b5ee187020e0000006361737065722d6578616d706c65130000006578616d706c652d656e7472792d706f696e7401000000080000007175616e7469747904000000e803000001050100000006000000616d6f756e7404000000e8030000010100000001d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c012dbf03817a51794a8e19e0724884075e6d1fbec326b766ecfa6658b41f81290da85e23b24e88b1c8d9761185c961daee1adab0649912a6477bcd2e69bd91bd08"
|
23
|
+
json_deploy = {
|
24
|
+
"hash": "01da3c604f71e0e7df83ff1ab4ef15bb04de64ca02e3d2b78de6950e8b5ee187",
|
25
|
+
"header": {
|
26
|
+
"account": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c",
|
27
|
+
"timestamp": "2020-11-17T00:39:24.072Z",
|
28
|
+
"ttl": "1h",
|
29
|
+
"gas_price": 1,
|
30
|
+
"body_hash": "4811966d37fe5674a8af4001884ea0d9042d1c06668da0c963769c3a01ebd08f",
|
31
|
+
"dependencies": [
|
32
|
+
"0101010101010101010101010101010101010101010101010101010101010101"
|
33
|
+
],
|
34
|
+
"chain_name": "casper-example"
|
35
|
+
},
|
36
|
+
"payment": {
|
37
|
+
"StoredContractByName": {
|
38
|
+
"name": "casper-example",
|
39
|
+
"entry_point": "example-entry-point",
|
40
|
+
"args": [
|
41
|
+
[
|
42
|
+
"quantity",
|
43
|
+
{
|
44
|
+
"cl_type": "I32",
|
45
|
+
"bytes": "e8030000",
|
46
|
+
"parsed": 1000
|
47
|
+
}
|
48
|
+
]
|
49
|
+
]
|
50
|
+
}
|
51
|
+
},
|
52
|
+
"session": {
|
53
|
+
"Transfer": {
|
54
|
+
"args": [
|
55
|
+
[
|
56
|
+
"amount",
|
57
|
+
{
|
58
|
+
"cl_type": "I32",
|
59
|
+
"bytes": "e8030000",
|
60
|
+
"parsed": 1000
|
61
|
+
}
|
62
|
+
]
|
63
|
+
]
|
64
|
+
}
|
65
|
+
},
|
66
|
+
"approvals": [
|
67
|
+
{
|
68
|
+
"signer": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c",
|
69
|
+
"signature": "012dbf03817a51794a8e19e0724884075e6d1fbec326b766ecfa6658b41f81290da85e23b24e88b1c8d9761185c961daee1adab0649912a6477bcd2e69bd91bd08"
|
70
|
+
}
|
71
|
+
]
|
72
|
+
}
|
73
|
+
deploy = Casper::Entity::Deploy.new(json_deploy[:hash], json_deploy[:header], json_deploy[:payment], json_deploy[:session], json_deploy[:approvals])
|
74
|
+
# puts Utils::ByteUtils.hex_to_byte_array(serializer.to_bytes(deploy))
|
75
|
+
expect(Utils::ByteUtils.byte_array_to_hex(serializer.to_bytes(deploy))).to eql(serialized_deploy)
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
require_relative '../lib/types/cl_string.rb'
|
2
|
+
require_relative '../lib/serialization/cl_value_bytes_parsers.rb'
|
3
|
+
require_relative '../lib/utils/time_utils.rb'
|
4
|
+
require_relative '../lib/utils/byte_utils.rb'
|
5
|
+
require_relative '../lib/types/cl_i32.rb'
|
6
|
+
require_relative '../lib/serialization/cl_value_serializer.rb'
|
7
|
+
|
8
|
+
|
9
|
+
RSpec.describe Utils::TimeUtils do
|
10
|
+
let(:time_utils) { Utils::TimeUtils }
|
11
|
+
let(:byte_utils) { Utils::ByteUtils }
|
12
|
+
|
13
|
+
it "should serialize Deploy" do
|
14
|
+
ms = time_utils.to_epoc_ms("2020-11-17T00:39:24.072Z")
|
15
|
+
timestamp_serialized = byte_utils.to_u64(ms)
|
16
|
+
puts "timestamp_serialized: #{timestamp_serialized}"
|
17
|
+
|
18
|
+
ttl_serialized = byte_utils.to_u64(3600000)
|
19
|
+
# ttl_serialized = byte_utils.to_u64(1603994401469)
|
20
|
+
puts "ttl_serialized: #{ttl_serialized}"
|
21
|
+
|
22
|
+
gas_price_serialized = byte_utils.to_u64(1)
|
23
|
+
puts "gas_price_serialized: #{gas_price_serialized}"
|
24
|
+
|
25
|
+
|
26
|
+
# payment *******************************************************************************************
|
27
|
+
str1 = CLString.new("casper-example")
|
28
|
+
bytes1 = str1.to_bytes(str1.get_value)
|
29
|
+
puts "#{str1.get_value}: #{bytes1}"
|
30
|
+
puts "#{CLValueBytesParsers::CLStringBytesParser.from_bytes("0e0000006361737065722d6578616d706c65")}: 0e0000006361737065722d6578616d706c65"
|
31
|
+
|
32
|
+
str2 = CLString.new("example-entry-point")
|
33
|
+
bytes2 = str2.to_bytes(str2.get_value)
|
34
|
+
puts "#{str2.get_value}: #{bytes2}"
|
35
|
+
puts "#{CLValueBytesParsers::CLStringBytesParser.from_bytes("130000006578616d706c652d656e7472792d706f696e74")}: 130000006578616d706c652d656e7472792d706f696e74"
|
36
|
+
|
37
|
+
# result_string = string.from_bytes(bytes)
|
38
|
+
|
39
|
+
num1 = CLi32.new(1000)
|
40
|
+
num1_bytes = byte_utils.to_i32(1000)
|
41
|
+
puts "#{num1.get_value}: #{num1_bytes}"
|
42
|
+
# num1_bytes = CLValueBytesParsers::CLI32BytesParser.to_bytes(num1)
|
43
|
+
|
44
|
+
# serialized_quantity = "080000007175616e74697479"
|
45
|
+
serialized_quantity = CLValueBytesParsers::CLStringBytesParser.to_bytes("quantity")
|
46
|
+
puts "quantity: #{serialized_quantity}"
|
47
|
+
# deserialized_quantity = "quantity"
|
48
|
+
deserialized_quantity = CLValueBytesParsers::CLStringBytesParser.from_bytes(serialized_quantity)
|
49
|
+
puts "deserialized_quantity: #{deserialized_quantity}"
|
50
|
+
puts "?????: #{CLValueBytesParsers::CLStringBytesParser.from_bytes("080000007175616e74697479")}"
|
51
|
+
|
52
|
+
#serialized_amount = "06000000616d6f756e74"
|
53
|
+
serialized_amount = CLValueBytesParsers::CLStringBytesParser.to_bytes("amount")
|
54
|
+
puts "amount: #{serialized_quantity}"
|
55
|
+
|
56
|
+
# deserialized_amount = "06000000616d6f756e74"
|
57
|
+
deserialized_amount = CLValueBytesParsers::CLStringBytesParser.from_bytes(serialized_amount)
|
58
|
+
puts "deserialized_amount: #{deserialized_amount}"
|
59
|
+
|
60
|
+
# "cl_type": "I32", "bytes": "e8030000", "parsed": 1000
|
61
|
+
serialized_i32 = byte_utils.to_i32(3)
|
62
|
+
# expect(byte_utils.to_u64(3600000)).to eql("80ee360000000000")
|
63
|
+
puts "# => #{CLValueBytesParsers::CLStringBytesParser.from_bytes("06000000616d6f756e74")}"
|
64
|
+
puts "# => #{CLValueBytesParsers::CLStringBytesParser.from_bytes("06000000616d6f756e74")}"
|
65
|
+
# puts "# => #{CLValueBytesParsers::CLStringBytesParser.from_bytes("0101000000")}"
|
66
|
+
puts "# => #{byte_utils.to_i32(1000)}"
|
67
|
+
puts "e8030000"
|
68
|
+
|
69
|
+
puts "********** U512 serialization ***********"
|
70
|
+
value = 3000000000
|
71
|
+
value = 123456789101112131415
|
72
|
+
# value = 7
|
73
|
+
str = value.to_s(16)
|
74
|
+
arr = str.scan(/[0-9a-f]{4}/).map { |x| x.to_i(16) }
|
75
|
+
packed = arr.pack("n*").unpack("C*").reverse()
|
76
|
+
packed = arr.pack("n*").unpack1("H*")
|
77
|
+
p "packed: " + packed
|
78
|
+
|
79
|
+
# ********************************************************************************************************
|
80
|
+
# It is not done yet!!!
|
81
|
+
ModuleBytes = {
|
82
|
+
module_bytes: "[72 bytes]",
|
83
|
+
args: "434705a38470ec2b008bb693426f47f330802f3bd63588ee275e943407649d3bab1898897ab0400d7fa09fe02ab7b7e8ea443d28069ca557e206916515a7e21d15e5be5eb46235f5"
|
84
|
+
}
|
85
|
+
expected_serialized = "0048000000420481b0d5a665c8a7678398103d4333c684461a71e9ee2a13f6e859fb6cd419ed5f8876fc6c3e12dce4385acc777edf42dcf8d8d844bf6a704e5b2446750559911a4a328d649ddd48000000434705a38470ec2b008bb693426f47f330802f3bd63588ee275e943407649d3bab1898897ab0400d7fa09fe02ab7b7e8ea443d28069ca557e206916515a7e21d15e5be5eb46235f5"
|
86
|
+
expected_serialized_prefix = "00"
|
87
|
+
expected_serialized_length1 = "48000000"
|
88
|
+
expected_serialized_module_bytes = "420481b0d5a665c8a7678398103d4333c684461a71e9ee2a13f6e859fb6cd419ed5f8876fc6c3e12dce4385acc777edf42dcf8d8d844bf6a704e5b2446750559911a4a328d649ddd"
|
89
|
+
|
90
|
+
|
91
|
+
expected_serialized_args_length = "48000000"
|
92
|
+
expected_serialized_args = "434705a38470ec2b008bb693426f47f330802f3bd63588ee275e943407649d3bab1898897ab0400d7fa09fe02ab7b7e8ea443d28069ca557e206916515a7e21d15e5be5eb46235f5"
|
93
|
+
|
94
|
+
# ********************************************************************************************************
|
95
|
+
StoredContractByHash = {
|
96
|
+
hash: "c4c411864f7b717c27839e56f6f1ebe5da3f35ec0043f437324325d65a22afa4",
|
97
|
+
entry_point: "pclphXwfYmCmdITj8hnh",
|
98
|
+
args: "d8b59728274edd2334ea328b3292ed15eaf9134f9a00dce31a87d9050570fb0267a4002c85f3a8384d2502733b2e46f44981df85fed5e4854200bbca313e3bca8d888a84a76a1c5b1b3d236a12401a2999d3cad003c9b9d98c92ab1850"
|
99
|
+
}
|
100
|
+
expected_serialized_prefix = "01"
|
101
|
+
expected_serialized_hash = "c4c411864f7b717c27839e56f6f1ebe5da3f35ec0043f437324325d65a22afa4"
|
102
|
+
expected_serialized_entry_point = "1400000070636c7068587766596d436d6449546a38686e68"
|
103
|
+
expected_serialized_length_of_args = "5d000000"
|
104
|
+
expected_serialized_args = "d8b59728274edd2334ea328b3292ed15eaf9134f9a00dce31a87d9050570fb0267a4002c85f3a8384d2502733b2e46f44981df85fed5e4854200bbca313e3bca8d888a84a76a1c5b1b3d236a12401a2999d3cad003c9b9d98c92ab1850"
|
105
|
+
expected_serialized = "01c4c411864f7b717c27839e56f6f1ebe5da3f35ec0043f437324325d65a22afa41400000070636c7068587766596d436d6449546a38686e685d000000d8b59728274edd2334ea328b3292ed15eaf9134f9a00dce31a87d9050570fb0267a4002c85f3a8384d2502733b2e46f44981df85fed5e4854200bbca313e3bca8d888a84a76a1c5b1b3d236a12401a2999d3cad003c9b9d98c92ab1850"
|
106
|
+
|
107
|
+
serialized_prefix = byte_utils.to_u8(1)
|
108
|
+
serialized_hash = StoredContractByHash[:hash]
|
109
|
+
serialized_entry_point = CLValueBytesParsers::CLStringBytesParser.to_bytes(StoredContractByHash[:entry_point])
|
110
|
+
serialized_length_of_args = byte_utils.to_u32(StoredContractByHash[:args].size/2)
|
111
|
+
serialized_args = serialized_length_of_args + StoredContractByHash[:args]
|
112
|
+
answer = serialized_prefix + serialized_hash + serialized_entry_point + serialized_args
|
113
|
+
p answer == expected_serialized
|
114
|
+
|
115
|
+
|
116
|
+
# ********************************************************************************************************
|
117
|
+
StoredContractByName = {
|
118
|
+
name: "U5A74bSZH8abT8HqVaK9",
|
119
|
+
entry_point: "gIetSxltnRDvMhWdxTqQ",
|
120
|
+
args: "07beadc3da884faa17454a"
|
121
|
+
}
|
122
|
+
|
123
|
+
# p CLValueBytesParsers::CLStringBytesParser.to_bytes(StoredContractByName[:entry_point])
|
124
|
+
expected_serialized_prefix = "02"
|
125
|
+
expected_serialized_name = "14000000553541373462535a483861625438487156614b39"
|
126
|
+
expected_serialized_entry_point = "140000006749657453786c746e5244764d68576478547151"
|
127
|
+
expected_serialized_args = "0b00000007beadc3da884faa17454a"
|
128
|
+
expected_serialized = "0214000000553541373462535a483861625438487156614b39140000006749657453786c746e5244764d685764785471510b00000007beadc3da884faa17454a"
|
129
|
+
|
130
|
+
serialized_prefix = "02"
|
131
|
+
serialized_name = CLValueBytesParsers::CLStringBytesParser.to_bytes(StoredContractByName[:name])
|
132
|
+
serialized_entry_point = CLValueBytesParsers::CLStringBytesParser.to_bytes(StoredContractByName[:entry_point])
|
133
|
+
serialized_length_of_args = byte_utils.to_u32(StoredContractByName[:args].size/2)
|
134
|
+
serialized_args = serialized_length_of_args + StoredContractByName[:args]
|
135
|
+
answer = serialized_prefix + serialized_name + serialized_entry_point + serialized_args
|
136
|
+
p answer == expected_serialized
|
137
|
+
|
138
|
+
# ********************************************************************************************************
|
139
|
+
StoredVersionedContractByHash = {
|
140
|
+
hash: "b348fdd0d0b3f66468687df93141b5924f6bb957d5893c08b60d5a78d0b9a423",
|
141
|
+
version: "None",
|
142
|
+
entry_point: "PsLz5c7JsqT8BK8ll0kF",
|
143
|
+
args: "3d0d7f193f70740386cb78b383e2e30c4f976cf3fa834bafbda4ed9dbfeb52ce1777817e8ed8868cfac6462b7cd31028aa5a7a60066db35371a2f8"
|
144
|
+
}
|
145
|
+
expected_serialized = "03b348fdd0d0b3f66468687df93141b5924f6bb957d5893c08b60d5a78d0b9a423001400000050734c7a3563374a73715438424b386c6c306b463b0000003d0d7f193f70740386cb78b383e2e30c4f976cf3fa834bafbda4ed9dbfeb52ce1777817e8ed8868cfac6462b7cd31028aa5a7a60066db35371a2f8"
|
146
|
+
|
147
|
+
expected_serialized_prefix = "03"
|
148
|
+
expected_serialized_hash = "b348fdd0d0b3f66468687df93141b5924f6bb957d5893c08b60d5a78d0b9a423"
|
149
|
+
expected_serialized_version = "00" # => u8
|
150
|
+
expected_serialized_entry_point = "1400000050734c7a3563374a73715438424b386c6c306b46"
|
151
|
+
expected_serialized_args = "3b0000003d0d7f193f70740386cb78b383e2e30c4f976cf3fa834bafbda4ed9dbfeb52ce1777817e8ed8868cfac6462b7cd31028aa5a7a60066db35371a2f8"
|
152
|
+
|
153
|
+
serialized_prefix = "03"
|
154
|
+
serialized_hash = StoredVersionedContractByHash[:hash]
|
155
|
+
serialized_version = byte_utils.to_u8(0)
|
156
|
+
serialized_entry_point = CLValueBytesParsers::CLStringBytesParser.to_bytes(StoredVersionedContractByHash[:entry_point])
|
157
|
+
serialized_length_of_args = byte_utils.to_u32(StoredVersionedContractByHash[:args].size/2)
|
158
|
+
serialized_args = serialized_length_of_args + StoredVersionedContractByHash[:args]
|
159
|
+
|
160
|
+
answer = serialized_prefix + serialized_hash + serialized_version + serialized_entry_point + serialized_args
|
161
|
+
p answer == expected_serialized
|
162
|
+
|
163
|
+
# ********************************************************************************************************
|
164
|
+
StoredVersionedContractByName = {
|
165
|
+
name: "lWJWKdZUEudSakJzw1tn",
|
166
|
+
version: "Some(1632552656)",
|
167
|
+
entry_point: "S1cXRT3E1jyFlWBAIVQ8",
|
168
|
+
args: "9975e6957ea6b07176c7d8471478fb28df9f02a61689ef58234b1a3cffaebf9f303e3ef60ae0d8"
|
169
|
+
}
|
170
|
+
expected_serialized = "04140000006c574a574b645a5545756453616b4a7a7731746e01d0c64e61140000005331635852543345316a79466c57424149565138270000009975e6957ea6b07176c7d8471478fb28df9f02a61689ef58234b1a3cffaebf9f303e3ef60ae0d8"
|
171
|
+
|
172
|
+
serialized_prefix = "04"
|
173
|
+
serialized_name = CLValueBytesParsers::CLStringBytesParser.to_bytes(StoredVersionedContractByName[:name])
|
174
|
+
serialized_version = "01d0c64e61"
|
175
|
+
serialized_entry_point = CLValueBytesParsers::CLStringBytesParser.to_bytes(StoredVersionedContractByName[:entry_point])
|
176
|
+
serialized_length_of_args = byte_utils.to_u32(StoredVersionedContractByName[:args].size/2)
|
177
|
+
serialized_args = serialized_length_of_args + StoredVersionedContractByName[:args]
|
178
|
+
|
179
|
+
answer = serialized_prefix + serialized_name + serialized_version + serialized_entry_point + serialized_args
|
180
|
+
p answer
|
181
|
+
p answer == expected_serialized
|
182
|
+
# ********************************************************************************************************
|
183
|
+
|
184
|
+
# Some(1632552656)
|
185
|
+
puts "01" + byte_utils.to_u32(1632552656)
|
186
|
+
# => 01d0c64e61
|
187
|
+
# None
|
188
|
+
puts "00"
|
189
|
+
puts byte_utils.to_u8(0)
|
190
|
+
# => "00"
|
191
|
+
puts CLValueBytesParsers::CLStringBytesParser.to_bytes("PsLz5c7JsqT8BK8ll0kF")
|
192
|
+
|
193
|
+
puts "byte_utils.to_u8(13): " + byte_utils.to_u8(13)
|
194
|
+
puts "byte_utils.to_i32(9): " + byte_utils.to_i32(9)
|
195
|
+
puts "byte_utils.to_i32(1000): " + byte_utils.to_i32(1000)
|
196
|
+
i32_hex_value = byte_utils.to_i32(1000)
|
197
|
+
# puts i32_hex_value
|
198
|
+
puts "byte_utils.hex_to_integer(i32_hex_value): " + byte_utils.hex_to_integer(i32_hex_value).to_s
|
199
|
+
|
200
|
+
puts "casper-test: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("casper-test")
|
201
|
+
puts "Hello World!: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("Hello World!")
|
202
|
+
puts "Hello, Casper!: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("Hello, Casper!")
|
203
|
+
|
204
|
+
|
205
|
+
end
|
206
|
+
describe CLValueSerializer do
|
207
|
+
let (:serializer) { CLValueSerializer.new }
|
208
|
+
|
209
|
+
it "Test serialize ModuleBytes " do
|
210
|
+
puts "payment: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("payment")
|
211
|
+
end
|
212
|
+
|
213
|
+
it "Test serialize storedContractByName " do
|
214
|
+
puts "quantity: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("quantity")
|
215
|
+
puts "casper-example: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("casper-example")
|
216
|
+
puts "example-entry-point: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("example-entry-point")
|
217
|
+
puts "PsLz5c7JsqT8BK8ll0kF: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("PsLz5c7JsqT8BK8ll0kF")
|
218
|
+
puts "pclphXwfYmCmdITj8hnh: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("pclphXwfYmCmdITj8hnh")
|
219
|
+
puts "lWJWKdZUEudSakJzw1tn: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("lWJWKdZUEudSakJzw1tn")
|
220
|
+
puts "S1cXRT3E1jyFlWBAIVQ8: " + CLValueBytesParsers::CLStringBytesParser.to_bytes("S1cXRT3E1jyFlWBAIVQ8")
|
221
|
+
puts "CLi32.new(1000): " + serializer.to_bytes(CLi32.new(1000))
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|