|
|
@ -16,8 +16,8 @@ func TestMessageSimpleWrap(t *testing.T) { |
|
|
|
if _, err := msg.Wrap(DefaultProofOfWork, Options{}); err != nil { |
|
|
|
if _, err := msg.Wrap(DefaultProofOfWork, Options{}); err != nil { |
|
|
|
t.Fatalf("failed to wrap message: %v", err) |
|
|
|
t.Fatalf("failed to wrap message: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
if msg.Flags&128 != 0 { |
|
|
|
if msg.Flags&signatureFlag != 0 { |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 0) |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, 0) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(msg.Signature) != 0 { |
|
|
|
if len(msg.Signature) != 0 { |
|
|
|
t.Fatalf("signature found for simple wrapping: 0x%x", msg.Signature) |
|
|
|
t.Fatalf("signature found for simple wrapping: 0x%x", msg.Signature) |
|
|
@ -41,8 +41,8 @@ func TestMessageCleartextSignRecover(t *testing.T) { |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
t.Fatalf("failed to sign message: %v", err) |
|
|
|
t.Fatalf("failed to sign message: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
if msg.Flags&128 != 128 { |
|
|
|
if msg.Flags&signatureFlag != signatureFlag { |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 1) |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, signatureFlag) |
|
|
|
} |
|
|
|
} |
|
|
|
if bytes.Compare(msg.Payload, payload) != 0 { |
|
|
|
if bytes.Compare(msg.Payload, payload) != 0 { |
|
|
|
t.Fatalf("payload mismatch after signing: have 0x%x, want 0x%x", msg.Payload, payload) |
|
|
|
t.Fatalf("payload mismatch after signing: have 0x%x, want 0x%x", msg.Payload, payload) |
|
|
@ -75,8 +75,8 @@ func TestMessageAnonymousEncryptDecrypt(t *testing.T) { |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to encrypt message: %v", err) |
|
|
|
t.Fatalf("failed to encrypt message: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
if msg.Flags&128 != 0 { |
|
|
|
if msg.Flags&signatureFlag != 0 { |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 0) |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, 0) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(msg.Signature) != 0 { |
|
|
|
if len(msg.Signature) != 0 { |
|
|
|
t.Fatalf("signature found for anonymous message: 0x%x", msg.Signature) |
|
|
|
t.Fatalf("signature found for anonymous message: 0x%x", msg.Signature) |
|
|
@ -111,8 +111,8 @@ func TestMessageFullCrypto(t *testing.T) { |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("failed to encrypt message: %v", err) |
|
|
|
t.Fatalf("failed to encrypt message: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
if msg.Flags&128 != 128 { |
|
|
|
if msg.Flags&signatureFlag != signatureFlag { |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", (msg.Flags&128)>>7, 1) |
|
|
|
t.Fatalf("signature flag mismatch: have %d, want %d", msg.Flags&signatureFlag, signatureFlag) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(msg.Signature) == 0 { |
|
|
|
if len(msg.Signature) == 0 { |
|
|
|
t.Fatalf("no signature found for signed message") |
|
|
|
t.Fatalf("no signature found for signed message") |
|
|
|