diff --git a/stellar-dotnet-sdk-test/responses/EffectDeserializerTest.cs b/stellar-dotnet-sdk-test/responses/EffectDeserializerTest.cs index 2aac18d54..f8bfb2702 100644 --- a/stellar-dotnet-sdk-test/responses/EffectDeserializerTest.cs +++ b/stellar-dotnet-sdk-test/responses/EffectDeserializerTest.cs @@ -602,6 +602,28 @@ public void TestSerializeDeserializeTradeEffect() AssertTradeData(back); } + //Before Horizon 1.0.0 the OfferID in the json was a long. + [TestMethod] + public void TestDeserializeTradeEffectPre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "effectTradePre100.json")); + var instance = JsonSingleton.GetInstance(json); + + AssertTradeData(instance); + } + + //Before Horizon 1.0.0 the OfferID in the json was a long. + [TestMethod] + public void TestSerializeDeserializeTradeEffectPre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "effectTradePre100.json")); + var instance = JsonSingleton.GetInstance(json); + var serialized = JsonConvert.SerializeObject(instance); + var back = JsonConvert.DeserializeObject(serialized); + + AssertTradeData(back); + } + private static void AssertTradeData(EffectResponse instance) { //There is a JsonConverter called OperationDeserializer that instantiates the type based on the json type_i element... diff --git a/stellar-dotnet-sdk-test/responses/OfferPageDeserializerTest.cs b/stellar-dotnet-sdk-test/responses/OfferPageDeserializerTest.cs index 3a9b613b8..5a8b012ab 100644 --- a/stellar-dotnet-sdk-test/responses/OfferPageDeserializerTest.cs +++ b/stellar-dotnet-sdk-test/responses/OfferPageDeserializerTest.cs @@ -30,6 +30,28 @@ public void TestSerializeDeserialize() AssertTestData(back); } + //Before Horizon 1.0.0 the ID in the json was a long. + [TestMethod] + public void TestDeserializePre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "offerPagePre100.json")); + var offerResponsePage = JsonSingleton.GetInstance>(json); + + AssertTestData(offerResponsePage); + } + + //Before Horizon 1.0.0 the ID in the json was a long. + [TestMethod] + public void TestSerializeDeserializePre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "offerPagePre100.json")); + var offerResponsePage = JsonSingleton.GetInstance>(json); + var serialized = JsonConvert.SerializeObject(offerResponsePage); + var back = JsonConvert.DeserializeObject>(serialized); + + AssertTestData(back); + } + public static void AssertTestData(Page offerResponsePage) { Assert.AreEqual(offerResponsePage.Records[0].Id, "241"); diff --git a/stellar-dotnet-sdk-test/responses/OperationDeserializerTest.cs b/stellar-dotnet-sdk-test/responses/OperationDeserializerTest.cs index af5e9405d..645a84eed 100644 --- a/stellar-dotnet-sdk-test/responses/OperationDeserializerTest.cs +++ b/stellar-dotnet-sdk-test/responses/OperationDeserializerTest.cs @@ -343,13 +343,35 @@ public void TestSerializeDeserializeManageBuyOfferOperation() AssertManageBuyOfferData(back); } + //Before Horizon 1.0.0 the OfferID in the json was a long. + [TestMethod] + public void TestDeserializeManageBuyOfferOperationPre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "operationManageBuyOfferPre100.json")); + var instance = JsonSingleton.GetInstance(json); + + AssertManageBuyOfferData(instance); + } + + //Before Horizon 1.0.0 the OfferID in the json was a long. + [TestMethod] + public void TestSerializeDeserializeManageBuyOfferOperationPre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "operationManageBuyOfferPre100.json")); + var instance = JsonSingleton.GetInstance(json); + var serialized = JsonConvert.SerializeObject(instance); + var back = JsonConvert.DeserializeObject(serialized); + + AssertManageBuyOfferData(back); + } + private static void AssertManageBuyOfferData(OperationResponse instance) { //There is a JsonConverter called OperationDeserializer that instantiates the type based on the json type_i element... Assert.IsTrue(instance is ManageBuyOfferOperationResponse); var operation = (ManageBuyOfferOperationResponse) instance; - Assert.AreEqual(operation.OfferId, "0"); + Assert.AreEqual(operation.OfferId, "1"); Assert.AreEqual(operation.Amount, "50000.0000000"); Assert.AreEqual(operation.Price, "0.0463000"); Assert.AreEqual(operation.BuyingAsset, diff --git a/stellar-dotnet-sdk-test/responses/TradeAggregationsPageDeserializerTest.cs b/stellar-dotnet-sdk-test/responses/TradeAggregationsPageDeserializerTest.cs index f13bd049b..2f46e9f54 100644 --- a/stellar-dotnet-sdk-test/responses/TradeAggregationsPageDeserializerTest.cs +++ b/stellar-dotnet-sdk-test/responses/TradeAggregationsPageDeserializerTest.cs @@ -29,6 +29,28 @@ public void TestSerializeDeserialize() AssertTestData(back); } + //Before Horizon 1.0.0 the Timestamp and TradeCount in the json were a long. + [TestMethod] + public void TestDeserializePre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "tradeAggregationsPagePre100.json")); + var tradeAggregationsPage = JsonSingleton.GetInstance>(json); + + AssertTestData(tradeAggregationsPage); + } + + //Before Horizon 1.0.0 the Timestamp and TradeCount in the json were a long. + [TestMethod] + public void TestSerializeDeserializePre100() + { + var json = File.ReadAllText(Path.Combine("testdata", "tradeAggregationsPagePre100.json")); + var tradeAggregationsPage = JsonSingleton.GetInstance>(json); + var serialized = JsonConvert.SerializeObject(tradeAggregationsPage); + var back = JsonConvert.DeserializeObject>(serialized); + + AssertTestData(back); + } + public static void AssertTestData(Page tradeAggregationsPage) { Assert.AreEqual(tradeAggregationsPage.Links.Next.Href, diff --git a/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj b/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj index 39b7c326b..a3ee80993 100644 --- a/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj +++ b/stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj @@ -68,6 +68,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -134,6 +137,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -155,6 +161,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -221,6 +230,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -236,7 +248,7 @@ PreserveNewest - + PreserveNewest diff --git a/stellar-dotnet-sdk-test/testdata/effectTrade.json b/stellar-dotnet-sdk-test/testdata/effectTrade.json index 9f82d8d35..34582b2f8 100644 --- a/stellar-dotnet-sdk-test/testdata/effectTrade.json +++ b/stellar-dotnet-sdk-test/testdata/effectTrade.json @@ -16,7 +16,7 @@ "type": "trade", "type_i": 33, "seller": "GCVHDLN6EHZBYW2M3BQIY32C23E4GPIRZZDBNF2Q73DAZ5VJDRGSMYRB", - "offer_id": 1, + "offer_id": "1", "sold_amount": "1000.0", "sold_asset_type": "credit_alphanum4", "sold_asset_code": "EUR", diff --git a/stellar-dotnet-sdk-test/testdata/effectTradePre100.json b/stellar-dotnet-sdk-test/testdata/effectTradePre100.json new file mode 100644 index 000000000..9f82d8d35 --- /dev/null +++ b/stellar-dotnet-sdk-test/testdata/effectTradePre100.json @@ -0,0 +1,28 @@ +{ + "_links": { + "operation": { + "href": "http://horizon-testnet.stellar.org/operations/33788507721730" + }, + "succeeds": { + "href": "http://horizon-testnet.stellar.org/effects?order=desc&cursor=33788507721730-2" + }, + "precedes": { + "href": "http://horizon-testnet.stellar.org/effects?order=asc&cursor=33788507721730-2" + } + }, + "id": "0000033788507721730-0000000002", + "paging_token": "33788507721730-2", + "account": "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO", + "type": "trade", + "type_i": 33, + "seller": "GCVHDLN6EHZBYW2M3BQIY32C23E4GPIRZZDBNF2Q73DAZ5VJDRGSMYRB", + "offer_id": 1, + "sold_amount": "1000.0", + "sold_asset_type": "credit_alphanum4", + "sold_asset_code": "EUR", + "sold_asset_issuer": "GCWVFBJ24754I5GXG4JOEB72GJCL3MKWC7VAEYWKGQHPVH3ENPNBSKWS", + "bought_amount": "60.0", + "bought_asset_type": "credit_alphanum12", + "bought_asset_code": "TESTTEST", + "bought_asset_issuer": "GAHXPUDP3AK6F2QQM4FIRBGPNGKLRDDSTQCVKEXXKKRHJZUUQ23D5BU7" +} diff --git a/stellar-dotnet-sdk-test/testdata/offerPage.json b/stellar-dotnet-sdk-test/testdata/offerPage.json index 7bce84e91..237c90037 100644 --- a/stellar-dotnet-sdk-test/testdata/offerPage.json +++ b/stellar-dotnet-sdk-test/testdata/offerPage.json @@ -21,7 +21,7 @@ "href": "https://horizon-testnet.stellar.org/accounts/GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD" } }, - "id": 241, + "id": "241", "paging_token": "241", "seller": "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD", "selling": { diff --git a/stellar-dotnet-sdk-test/testdata/offerPagePre100.json b/stellar-dotnet-sdk-test/testdata/offerPagePre100.json new file mode 100644 index 000000000..7bce84e91 --- /dev/null +++ b/stellar-dotnet-sdk-test/testdata/offerPagePre100.json @@ -0,0 +1,48 @@ +{ + "_links": { + "self": { + "href": "https://horizon-testnet.stellar.org/accounts/GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD/offers?order=asc&limit=10&cursor=" + }, + "next": { + "href": "https://horizon-testnet.stellar.org/accounts/GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD/offers?order=asc&limit=10&cursor=241" + }, + "prev": { + "href": "https://horizon-testnet.stellar.org/accounts/GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD/offers?order=desc&limit=10&cursor=241" + } + }, + "_embedded": { + "records": [ + { + "_links": { + "self": { + "href": "https://horizon-testnet.stellar.org/offers/241" + }, + "offer_maker": { + "href": "https://horizon-testnet.stellar.org/accounts/GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD" + } + }, + "id": 241, + "paging_token": "241", + "seller": "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD", + "selling": { + "asset_type": "credit_alphanum4", + "asset_code": "INR", + "asset_issuer": "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD" + }, + "buying": { + "asset_type": "credit_alphanum4", + "asset_code": "USD", + "asset_issuer": "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD" + }, + "amount": "10.0000000", + "price_r": { + "n": 10, + "d": 1 + }, + "price": "11.0000000", + "last_modified_ledger": 22200794, + "last_modified_time": "2019-01-28T12:30:38Z" + } + ] + } +} \ No newline at end of file diff --git a/stellar-dotnet-sdk-test/testdata/operationManageBuyOffer.json b/stellar-dotnet-sdk-test/testdata/operationManageBuyOffer.json index e90203357..a67b907de 100644 --- a/stellar-dotnet-sdk-test/testdata/operationManageBuyOffer.json +++ b/stellar-dotnet-sdk-test/testdata/operationManageBuyOffer.json @@ -34,5 +34,5 @@ "buying_asset_code": "RMT", "buying_asset_issuer": "GDEGOXPCHXWFYY234D2YZSPEJ24BX42ESJNVHY5H7TWWQSYRN5ZKZE3N", "selling_asset_type": "native", - "offer_id": 0 + "offer_id": "1" } \ No newline at end of file diff --git a/stellar-dotnet-sdk-test/testdata/operationManageBuyOfferPre100.json b/stellar-dotnet-sdk-test/testdata/operationManageBuyOfferPre100.json new file mode 100644 index 000000000..ea8e754a0 --- /dev/null +++ b/stellar-dotnet-sdk-test/testdata/operationManageBuyOfferPre100.json @@ -0,0 +1,38 @@ +{ + "_links": { + "self": { + "href": "https://horizon.stellar.org/operations/105020235379187713" + }, + "transaction": { + "href": "https://horizon.stellar.org/transactions/35b08c8e7fc739ab07fd8eeb9564c59b4f1e85099aa2d3b1d37ed86a6cb5c438" + }, + "effects": { + "href": "https://horizon.stellar.org/operations/105020235379187713/effects" + }, + "succeeds": { + "href": "https://horizon.stellar.org/effects?order=desc&cursor=105020235379187713" + }, + "precedes": { + "href": "https://horizon.stellar.org/effects?order=asc&cursor=105020235379187713" + } + }, + "id": "105020235379187713", + "paging_token": "105020235379187713", + "transaction_successful": true, + "source_account": "GDID4M4PAN3C2JO4PJPCZ4Z6PSYUTW2I32E5EBORECQYIJDGTIZO3N5D", + "type": "manage_buy_offer", + "type_i": 12, + "created_at": "2019-06-21T08:24:48Z", + "transaction_hash": "35b08c8e7fc739ab07fd8eeb9564c59b4f1e85099aa2d3b1d37ed86a6cb5c438", + "amount": "50000.0000000", + "price": "0.0463000", + "price_r": { + "n": 463, + "d": 10000 + }, + "buying_asset_type": "credit_alphanum4", + "buying_asset_code": "RMT", + "buying_asset_issuer": "GDEGOXPCHXWFYY234D2YZSPEJ24BX42ESJNVHY5H7TWWQSYRN5ZKZE3N", + "selling_asset_type": "native", + "offer_id": 1 +} \ No newline at end of file diff --git a/stellar-dotnet-sdk-test/testdata/tradeAggregationsPage.json b/stellar-dotnet-sdk-test/testdata/tradeAggregationsPage.json index fcd05fe6f..c14d714ff 100644 --- a/stellar-dotnet-sdk-test/testdata/tradeAggregationsPage.json +++ b/stellar-dotnet-sdk-test/testdata/tradeAggregationsPage.json @@ -10,8 +10,8 @@ "_embedded": { "records": [ { - "timestamp": 1517522400000, - "trade_count": 26, + "timestamp": "1517522400000", + "trade_count": "26", "base_volume": "27575.0201596", "counter_volume": "5085.6410385", "avg": "0.1844293", diff --git a/stellar-dotnet-sdk-test/testdata/tradeAggregationsPagePre100.json b/stellar-dotnet-sdk-test/testdata/tradeAggregationsPagePre100.json new file mode 100644 index 000000000..fcd05fe6f --- /dev/null +++ b/stellar-dotnet-sdk-test/testdata/tradeAggregationsPagePre100.json @@ -0,0 +1,68 @@ +{ + "_links": { + "self": { + "href": "https://horizon.stellar.org/trade_aggregations?base_asset_type=native&counter_asset_code=SLT&counter_asset_issuer=GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP&counter_asset_type=credit_alphanum4&limit=200&order=asc&resolution=3600000&start_time=1517521726000&end_time=1517532526000" + }, + "next": { + "href": "https://horizon.stellar.org/trade_aggregations?base_asset_type=native&counter_asset_code=SLT&counter_asset_issuer=GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP&counter_asset_type=credit_alphanum4&end_time=1517532526000&limit=200&order=asc&resolution=3600000&start_time=1517529600000" + } + }, + "_embedded": { + "records": [ + { + "timestamp": 1517522400000, + "trade_count": 26, + "base_volume": "27575.0201596", + "counter_volume": "5085.6410385", + "avg": "0.1844293", + "high": "0.1915709", + "high_r": { + "N": 50, + "D": 261 + }, + "low": "0.1506024", + "low_r": { + "N": 25, + "D": 166 + }, + "open": "0.1724138", + "open_r": { + "N": 5, + "D": 29 + }, + "close": "0.1506024", + "close_r": { + "N": 25, + "D": 166 + } + }, + { + "timestamp": 1517526000000, + "trade_count": 15, + "base_volume": "3913.8224543", + "counter_volume": "719.4993608", + "avg": "0.1838355", + "high": "0.1960784", + "high_r": { + "N": 10, + "D": 51 + }, + "low": "0.1506024", + "low_r": { + "N": 25, + "D": 166 + }, + "open": "0.1869159", + "open_r": { + "N": 20, + "D": 107 + }, + "close": "0.1515152", + "close_r": { + "N": 5, + "D": 33 + } + } + ] + } +}