MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestPubKeyHashAndAddressing

Function TestPubKeyHashAndAddressing

crypto/address_test.go:28–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestPubKeyHashAndAddressing(t *testing.T) {
29 testPubkeyAndAddr := []struct {
30 pubkey string
31 addr string
32 }{
33 {
34 pubkey: "0367aa51809a7c1dc0f82c02452fec9557b3e1d10ce7c919d8e73d90048df86d20",
35 addr: "ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37",
36 },
37 {
38 pubkey: "02914bca0806f040dd842207c44474ab41ecd29deee7f2d355789c5c78d448ca16",
39 addr: "1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be",
40 },
41 {
42 pubkey: "02ec784ca599f21ef93fe7abdc68d78817ab6c9b31f2324d15ea174d9da498b4c4",
43 addr: "9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd",
44 },
45 {
46 pubkey: "03ae859eac5b72ee428c7a85f10b2ce748d9de5e480aefbb70f6597dfa8b2175e5",
47 addr: "9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16",
48 },
49 {
50 pubkey: "02c1db96f2ba7e1cb4e9822d12de0f63fb666feb828c7f509e81fab9bd7a34039c",
51 addr: "58aceaf4b730b54bf00c0fb3f7b14886de470767f313c2d108968cd8bf0794b7",
52 },
53 }
54
55 Convey("Test the public key and address", t, func() {
56 for i := range testPubkeyAndAddr {
57 pubByte, err := hex.DecodeString(testPubkeyAndAddr[i].pubkey)
58 So(err, ShouldBeNil)
59 pub, _ := asymmetric.ParsePubKey(pubByte)
60 addr, err := PubKeyHash(pub)
61 So(addr.String(), ShouldEqual, testPubkeyAndAddr[i].addr)
62 So(err, ShouldBeNil)
63 }
64 })
65}

Callers

nothing calls this directly

Calls 3

ParsePubKeyFunction · 0.92
PubKeyHashFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected