From b29a93b358b6669d951d4902c0bed6e1d67039fc Mon Sep 17 00:00:00 2001 From: Jun Luo <4catcode@gmail.com> Date: Wed, 15 Jun 2022 00:55:20 +0800 Subject: [PATCH] protocols/horizon: Add missing strkey type names. (#4429) --- protocols/horizon/main.go | 10 ++++++---- protocols/horizon/main_test.go | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/protocols/horizon/main.go b/protocols/horizon/main.go index e5862805d8..5b261e7517 100644 --- a/protocols/horizon/main.go +++ b/protocols/horizon/main.go @@ -21,10 +21,12 @@ import ( // KeyTypeNames maps from strkey version bytes into json string values to use in // horizon responses. var KeyTypeNames = map[strkey.VersionByte]string{ - strkey.VersionByteAccountID: "ed25519_public_key", - strkey.VersionByteSeed: "ed25519_secret_seed", - strkey.VersionByteHashX: "sha256_hash", - strkey.VersionByteHashTx: "preauth_tx", + strkey.VersionByteAccountID: "ed25519_public_key", + strkey.VersionByteSeed: "ed25519_secret_seed", + strkey.VersionByteMuxedAccount: "muxed_account", + strkey.VersionByteHashTx: "preauth_tx", + strkey.VersionByteHashX: "sha256_hash", + strkey.VersionByteSignedPayload: "ed25519_signed_payload", } // Account is the summary of an account diff --git a/protocols/horizon/main_test.go b/protocols/horizon/main_test.go index 17f5f2ba10..1225fd7e90 100644 --- a/protocols/horizon/main_test.go +++ b/protocols/horizon/main_test.go @@ -238,3 +238,21 @@ func TestTradeAggregation_PagingToken(t *testing.T) { ta := TradeAggregation{Timestamp: 64} assert.Equal(t, "64", ta.PagingToken()) } + +func TestMustKeyTypeFromAddress(t *testing.T) { + tests := []struct { + address string + keyType string + }{ + {"GBUYDJH3AOPFFND3L54DUDWIHOMYKUONDV4RAHOHDBNN2D5N4BPPWDQ3", "ed25519_public_key"}, + {"SBUYDJH3AOPFFND3L54DUDWIHOMYKUONDV4RAHOHDBNN2D5N4BPPXHDE", "ed25519_secret_seed"}, + {"MBUYDJH3AOPFFND3L54DUDWIHOMYKUONDV4RAHOHDBNN2D5N4BPPWAAAAAAAAAPCIBYBE", "muxed_account"}, + {"TBUYDJH3AOPFFND3L54DUDWIHOMYKUONDV4RAHOHDBNN2D5N4BPPX6CK", "preauth_tx"}, + {"XBUYDJH3AOPFFND3L54DUDWIHOMYKUONDV4RAHOHDBNN2D5N4BPPW2HT", "sha256_hash"}, + {"PBUYDJH3AOPFFND3L54DUDWIHOMYKUONDV4RAHOHDBNN2D5N4BPPWAAAAACWQZLMNRXQAAAA22YA", "ed25519_signed_payload"}, + } + + for _, test := range tests { + assert.Equal(t, MustKeyTypeFromAddress(test.address), test.keyType) + } +}