From d0b64cd64a18a6116267fa09a837d62c19cced42 Mon Sep 17 00:00:00 2001 From: Zeyla Hellyer Date: Sat, 10 Jun 2017 21:55:33 -0700 Subject: Fix negative nonces failing to deserialize Negative message nonces caused deserialization errors, as serde would not deserialize integers into strings. To fix this, change `Message::nonce` into an `Option` from an `Option`. This new `Snowflake` is a wrapper around an `i64`. Use a new `I64Visitor` to deserialize i64s, u64s, and strs into the wanted i64. --- tests/resources/message_create_2.json | 23 +++++++++++++++++++++++ tests/test_deser.rs | 4 ++++ 2 files changed, 27 insertions(+) create mode 100644 tests/resources/message_create_2.json (limited to 'tests') diff --git a/tests/resources/message_create_2.json b/tests/resources/message_create_2.json new file mode 100644 index 0000000..f999397 --- /dev/null +++ b/tests/resources/message_create_2.json @@ -0,0 +1,23 @@ +{ + "type": 0, + "tts": false, + "timestamp": "2017-01-01T01:01:01.100000+00:00", + "pinned": false, + "nonce": -6000000000000000, + "mentions": [], + "mention_roles": [], + "mention_everyone": false, + "id": "300000000000000000", + "embeds": [], + "edited_timestamp": null, + "content": "fake", + "channel_id": "100000000000000000", + "author": { + "username": "fake", + "id": "300000000000000000", + "discriminator": "1234", + "bot": true, + "avatar": "f133549aac3208319a9fbc3c12345678" + }, + "attachments": [] +} diff --git a/tests/test_deser.rs b/tests/test_deser.rs index f4387bc..1024492 100644 --- a/tests/test_deser.rs +++ b/tests/test_deser.rs @@ -111,7 +111,11 @@ fn guild_update() { #[test] fn message_create() { + // standard p!(MessageCreateEvent, "message_create_1"); + + // negative nonce + p!(MessageCreateEvent, "message_create_2"); } #[test] -- cgit v1.2.3