From 4d3a01974c52eb35c17971f1ef97da80ed5a2ebb Mon Sep 17 00:00:00 2001 From: Pietro Date: Tue, 12 Jun 2018 18:01:06 +0200 Subject: [PATCH] [proto]: Remove commas from decimal repr of tezos --- src/bin_client/test/test_basic.sh | 21 +++++++------- src/bin_client/test/test_contracts.sh | 6 ++-- .../lib_baking/test/test_michelson_parser.ml | 28 +++++++++---------- .../lib_client/client_proto_args.ml | 5 ++-- src/proto_alpha/lib_protocol/src/qty_repr.ml | 4 +-- 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/bin_client/test/test_basic.sh b/src/bin_client/test/test_basic.sh index 58978dd22..ff62fa20b 100755 --- a/src/bin_client/test/test_basic.sh +++ b/src/bin_client/test/test_basic.sh @@ -43,18 +43,17 @@ bake_after $client transfer 2,000 from bootstrap1 to $key2 bake_after $client transfer 3,000 from bootstrap1 to $key3 # bake_after $client transfer 4,000 from bootstrap1 to $key6 -$client get balance for $key1 | assert "1,000 ꜩ" -$client get balance for $key2 | assert "2,000 ꜩ" -$client get balance for $key3 | assert "3,000 ꜩ" -# $client get balance for $key6 | assert "4,000 ꜩ" +$client get balance for $key1 | assert "1000 ꜩ" +$client get balance for $key2 | assert "2000 ꜩ" +$client get balance for $key3 | assert "3000 ꜩ" bake_after $client transfer 1,000 from $key2 to $key1 -fee 0 -$client get balance for $key1 | assert "2,000 ꜩ" -$client get balance for $key2 | assert "1,000 ꜩ" +$client get balance for $key1 | assert "2000 ꜩ" +$client get balance for $key2 | assert "1000 ꜩ" bake_after $client transfer 1,000 from $key1 to $key2 $client get balance for $key1 | assert "999.95 ꜩ" -$client get balance for $key2 | assert "2,000 ꜩ" +$client get balance for $key2 | assert "2000 ꜩ" # Should fail # $client transfer 999.95 from $key2 to $key1 @@ -84,16 +83,16 @@ bake_after $client register key $key2 as delegate bake_after $client set delegate for free_account to $key2 $client get delegate for free_account -$client get balance for bootstrap5 | assert "4,000,000 ꜩ" +$client get balance for bootstrap5 | assert "4000000 ꜩ" bake_after $client transfer 400,000 from bootstrap5 to bootstrap1 -fee 0 bake_after $client transfer 400,000 from bootstrap1 to bootstrap5 -fee 0 -$client get balance for bootstrap5 | assert "4,000,000 ꜩ" +$client get balance for bootstrap5 | assert "4000000 ꜩ" bake_after $client activate account $key4 with king_commitment.json bake_after $client activate account $key5 with queen_commitment.json -$client get balance for $key4 | assert "23,932,454.669,343 ꜩ" -$client get balance for $key5 | assert "72,954,577.464,032 ꜩ" +$client get balance for $key4 | assert "23932454.669343 ꜩ" +$client get balance for $key5 | assert "72954577.464032 ꜩ" bake_after $client transfer 10 from $key4 to $key5 diff --git a/src/bin_client/test/test_contracts.sh b/src/bin_client/test/test_contracts.sh index 8483c55aa..8b822907b 100755 --- a/src/bin_client/test/test_contracts.sh +++ b/src/bin_client/test/test_contracts.sh @@ -332,8 +332,8 @@ assert_storage $contract_dir/hash_key.tz None '"edpkuJqtDcA2m2muMxViSM47MPsGQzmy bake_after $client transfer 1,000 from bootstrap1 to $key1 bake_after $client transfer 2,000 from bootstrap1 to $key2 -assert_balance $key1 "1,000 ꜩ" -assert_balance $key2 "2,000 ꜩ" +assert_balance $key1 "1000 ꜩ" +assert_balance $key2 "2000 ꜩ" # Create a contract and transfer 100 ꜩ to it init_with_transfer $contract_dir/store_input.tz $key1 '""' 100 bootstrap1 @@ -409,7 +409,7 @@ assert_storage_contains $created_contract '"abcdefg"' init_with_transfer $contract_dir/default_account.tz $key1 \ Unit 1,000 bootstrap1 bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$BOOTSTRAP4_IDENTITY\"" -assert_balance $BOOTSTRAP4_IDENTITY "4,000,100 ꜩ" +assert_balance $BOOTSTRAP4_IDENTITY "4000100 ꜩ" account=tz1SuakBpFdG9b4twyfrSMqZzruxhpMeSrE5 bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$account\"" assert_balance $account "100 ꜩ" diff --git a/src/proto_alpha/lib_baking/test/test_michelson_parser.ml b/src/proto_alpha/lib_baking/test/test_michelson_parser.ml index 502409d3d..78c8960a1 100644 --- a/src/proto_alpha/lib_baking/test/test_michelson_parser.ml +++ b/src/proto_alpha/lib_baking/test/test_michelson_parser.ml @@ -13,26 +13,26 @@ module Assert = Helpers.Assert let known_ok_tez_litterals = [ 0L, "0" ; - 10L, "0.000,01" ; - 100L, "0.000,1" ; + 10L, "0.00001" ; + 100L, "0.0001" ; 1_000L, "0.001" ; 10_000L, "0.01" ; 100_000L, "0.1" ; 1_000_000L, "1" ; 10_000_000L, "10" ; 100_000_000L, "100" ; - 1_000_000_000L, "1,000" ; - 10_000_000_000L, "10,000" ; - 100_000_000_000L, "100,000" ; - 1_000_000_000_000L, "1,000,000" ; - 1_000_000_000_001L, "1,000,000.000,001" ; - 1_000_000_000_010L, "1,000,000.000,01" ; - 1_000_000_000_100L, "1,000,000.000,1" ; - 1_000_000_001_000L, "1,000,000.001" ; - 1_000_000_010_000L, "1,000,000.01" ; - 1_000_000_100_000L, "1,000,000.1" ; - 123_123_123_123_123_123L, "123,123,123,123.123,123" ; - 999_999_999_999_999_999L, "999,999,999,999.999,999" ] + 1_000_000_000L, "1000" ; + 10_000_000_000L, "10000" ; + 100_000_000_000L, "100000" ; + 1_000_000_000_000L, "1000000" ; + 1_000_000_000_001L, "1000000.000001" ; + 1_000_000_000_010L, "1000000.00001" ; + 1_000_000_000_100L, "1000000.0001" ; + 1_000_000_001_000L, "1000000.001" ; + 1_000_000_010_000L, "1000000.01" ; + 1_000_000_100_000L, "1000000.1" ; + 123_123_123_123_123_123L, "123123123123.123123" ; + 999_999_999_999_999_999L, "999999999999.999999" ] let known_bad_tez_litterals = [ "10000." ; diff --git a/src/proto_alpha/lib_client/client_proto_args.ml b/src/proto_alpha/lib_client/client_proto_args.ml index fc27d82a4..68126658a 100644 --- a/src/proto_alpha/lib_client/client_proto_args.ml +++ b/src/proto_alpha/lib_client/client_proto_args.ml @@ -120,10 +120,9 @@ let delegatable_switch = () let tez_format = - "Text format: `D,DDD,DDD.DDD,DDD`.\n\ + "Text format: `DDDDDDD.DDDDDD`.\n\ Tez and mutez and separated by a period sign. Trailing and pending \ - zeroes are allowed. Commas are optional, but if present they must \ - be placed every 3 digits." + zeroes are allowed." let tez_parameter param = parameter diff --git a/src/proto_alpha/lib_protocol/src/qty_repr.ml b/src/proto_alpha/lib_protocol/src/qty_repr.ml index ebc853e02..acf2bc8cc 100644 --- a/src/proto_alpha/lib_protocol/src/qty_repr.ml +++ b/src/proto_alpha/lib_protocol/src/qty_repr.ml @@ -128,7 +128,7 @@ module Make (T: QTY) : S = struct let rec left ppf amount = let d, r = Int64.(div amount 1000L), Int64.(rem amount 1000L) in if d > 0L then - Format.fprintf ppf "%a,%03Ld" left d r + Format.fprintf ppf "%a%03Ld" left d r else Format.fprintf ppf "%Ld" r in let right ppf amount = @@ -143,7 +143,7 @@ module Make (T: QTY) : S = struct if Compare.Int.(lo = 0) then Format.fprintf ppf "%a" triplet hi else - Format.fprintf ppf "%03d,%a" hi triplet lo in + Format.fprintf ppf "%03d%a" hi triplet lo in let ints, decs = Int64.(div amount mult_int), Int64.(to_int (rem amount mult_int)) in