Commit cc8cf545 authored by Éloïs's avatar Éloïs

[tests] add test_parse_peer_v11

parent e3af5550
......@@ -3,6 +3,8 @@
#![cfg(target_arch = "wasm32")]
extern crate dup_tools_wasm;
#[macro_use]
extern crate pretty_assertions;
extern crate wasm_bindgen_test;
use dup_tools_wasm::crypto::*;
......@@ -11,6 +13,19 @@ use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
fn test_generate_ed25519_keypair() {
let pubkey = generate_ed25519_pubkey(
"JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV",
"JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV_",
);
assert_eq!(
pubkey.as_str(),
"7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb"
);
}
#[wasm_bindgen_test]
fn test_parse_idty_v10() {
let doc = "Version: 10
......@@ -22,8 +37,29 @@ Timestamp: 0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
1eubHHbuNfilHMM0G2bI30iZzebQ2cQ1PC7uPAw08FGMMmQCRerlF/3pc4sAcsnexsxBseA/3lY03KlONqJBAg==";
assert_eq!(
parse_doc_into_json(doc, DocumentType::IdentityV10),
"{\n \"currency\": \"duniter_unit_test_currency\",\n \"username\": \"tic\",\n \"blockstamp\": \"0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855\",\n \"issuer\": \"DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV\",\n \"signature\": \"1eubHHbuNfilHMM0G2bI30iZzebQ2cQ1PC7uPAw08FGMMmQCRerlF/3pc4sAcsnexsxBseA/3lY03KlONqJBAg==\"\n}".to_owned()
parse_doc_into_json(doc, DocumentType::Any),
"{\n \"Identity\": {\n \"currency\": \"duniter_unit_test_currency\",\n \"username\": \"tic\",\n \"blockstamp\": \"0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855\",\n \"issuer\": \"DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV\",\n \"signature\": \"1eubHHbuNfilHMM0G2bI30iZzebQ2cQ1PC7uPAw08FGMMmQCRerlF/3pc4sAcsnexsxBseA/3lY03KlONqJBAg==\"\n }\n}".to_owned()
);
assert_eq!(
parse_doc_and_verify(doc, DocumentType::Any),
DocCheckResult::ValidSig,
);
}
#[wasm_bindgen_test]
fn test_parse_peer_v11() {
let doc = "11:g1:0:7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb:50-000005B1CEB4EC5245EF7E33101A330A1C9A358EC45A25FC13F78BB58C9E7370
WS2P V2 S 7 g1.durs.ifee.fr 443 ws2p
WS2P V2 S 7 84.16.72.210 443 ws2p
EQ2D5almq2RNUi3XZNtTpjo9nWtJF0PzsCW7ROAzCQKiEtpI7/fW8Z23GJ2a/SIxfYSzlq/cZqksE4EoVe1rAw==";
assert_eq!(
parse_doc_into_json(doc, DocumentType::Any),
"{\n \"currency_name\": \"g1\",\n \"issuer\": \"7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb\",\n \"node_id\": \"0\",\n \"blockstamp\": \"50-000005B1CEB4EC5245EF7E33101A330A1C9A358EC45A25FC13F78BB58C9E7370\",\n \"endpoints\": [\n \"WS2P V2 S 7 g1.durs.ifee.fr 443 ws2p\",\n \"WS2P V2 S 7 84.16.72.210 443 ws2p\"\n ],\n \"sig\": \"EQ2D5almq2RNUi3XZNtTpjo9nWtJF0PzsCW7ROAzCQKiEtpI7/fW8Z23GJ2a/SIxfYSzlq/cZqksE4EoVe1rAw==\"\n}".to_owned()
);
assert_eq!(
parse_doc_and_verify(doc, DocumentType::Any),
DocCheckResult::ValidSig,
);
}
......@@ -35,16 +71,3 @@ fn test_verify_sig() {
"WDgS+ZtHgMLjcBOVCRAelldrfYpJka64A8ICIwQW4dX/AR/bNrMfbj3hSZSzF+27ClJ4Z6wH1jDwMHHGOiNsCQ=="
));
}
#[wasm_bindgen_test]
fn test_generate_ed25519_keypair() {
let pubkey = generate_ed25519_pubkey(
"JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV",
"JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV_",
);
assert_eq!(
pubkey.as_str(),
"7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb"
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment