stellar-strkey 0.0.8

Encode and decode strkeys for Stellar.
Documentation
use stellar_strkey::*;

extern crate proptest;

#[test]
fn test_ed25519_public_key() {
    assert_eq!(
        format!(
            "{:?}",
            Strkey::PublicKeyEd25519(ed25519::PublicKey([
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
            ]))
        ),
        "PublicKeyEd25519(PublicKey(0000000000000000000000000000000000000000000000000000000000000000))",
    );
}

#[test]
fn test_ed25519_private_key() {
    assert_eq!(
        format!(
            "{:?}",
            Strkey::PrivateKeyEd25519(ed25519::PrivateKey([
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
            ]))
        ),
        "PrivateKeyEd25519(PrivateKey(0000000000000000000000000000000000000000000000000000000000000000))",
    );
}

#[test]
fn test_contract() {
    assert_eq!(
        format!(
            "{:?}",
            Strkey::Contract(Contract([
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
            ]))
        ),
        "Contract(Contract(0000000000000000000000000000000000000000000000000000000000000000))",
    );
}

#[test]
fn test_hash_x() {
    assert_eq!(
        format!(
            "{:?}",
            Strkey::HashX(HashX([
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
            ]))
        ),
        "HashX(HashX(0000000000000000000000000000000000000000000000000000000000000000))",
    );
}

#[test]
fn test_pre_auth_tx() {
    assert_eq!(
        format!(
            "{:?}",
            Strkey::PreAuthTx(PreAuthTx([
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
            ]))
        ),
        "PreAuthTx(PreAuthTx(0000000000000000000000000000000000000000000000000000000000000000))",
    );
}

#[test]
fn test_ed25519_muxed_account() {
    assert_eq!(
        format!(
            "{:?}",
            Strkey::MuxedAccountEd25519(ed25519::MuxedAccount {
                ed25519: [
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                ],
                id: 0,
            })
        ),
        "MuxedAccountEd25519(MuxedAccount(0000000000000000000000000000000000000000000000000000000000000000, 0))",
    );
}

#[test]
fn test_ed25519_signed_payload() {
    assert_eq!(
        format!(
            "{:?}",
            Strkey::SignedPayloadEd25519(ed25519::SignedPayload {
                ed25519: [
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                ],
                payload: [1, 2, 3, 4].into(),
            })
        ),
        "SignedPayloadEd25519(MuxedAccount(0000000000000000000000000000000000000000000000000000000000000000, 01020304))",
    );
}