Skip to content

Commit

Permalink
Working on verify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Oct 30, 2020
1 parent 586e2d7 commit 175891f
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 25 deletions.
74 changes: 65 additions & 9 deletions sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,71 @@ func TestSignMessage(t *testing.T) {
expectedSignature string
expectedError bool
}{
{"ef0b8bad0be285099534277fde328f8f19b3be9cadcd4c08e6ac0b5f863745ac", "This is a test message", "H+zZagsyz7ioC/ZOa5EwsaKice0vs2BvZ0ljgkFHxD3vGsMlGeD4sXHEcfbI4h8lP29VitSBdf4A+nHXih7svf4=", false},
{"93596babb564cbbdc84f2370c710b9bcc94333495b60af719b5fcf9ba00ba82c", "This is a test message", "IIuDw09ffPgEDuxEw5yHVp1+mi4QpuhAwLyQdpMTfsHCOkMqTKXuP7dSNWMEJqZsiQ8eKMDRvf2wZ4e5bxcu4O0=", false},
{"50381cf8f52936faae4a05a073a03d688a9fa206d005e87a39da436c75476d78", "This is a test message", "ILBmbjCY2Z7eSXGXZoBI3x2ZRaYUYOGtEaDjXetaY+zNDtMOvagsOGEHnVT3f5kXlEbuvmPydHqLnyvZP3cDOWk=", false},
{"c7726663147afd1add392d129086e57c0b05aa66a6ded564433c04bd55741434", "This is a test message", "IOI207QUnTLr2Ll+s4kUxNgLgorkc/Z5Pc+XNvUBYLy2TxaU6oHEJ2TTJ1mZVrtUyHm6e315v1tIjeosW3Odfqw=", false},
{"c7726663147afd1add392d129086e57c0b05aa66a6ded564433c04bd55741434", "1", "IMcRFG1VNN9TDGXpCU+9CqKLNOuhwQiXI5hZpkTOuYHKBDOWayNuAABofYLqUHYTMiMf9mYFQ0sPgFJZz3F7ELQ=", false},
{"", "This is a test message", "", true},
{"0", "This is a test message", "", true},
{"0000000", "This is a test message", "", true},
{"c7726663147afd1add392d129086e57c0b", "This is a test message", "H6N+iPf23i2YkLsNzF/yyeBm9eSYBoY/HFV1Md1F0ElWBXW5E5mkdRtgjoRuq0yNb1CCFNWWlkn2gZknFJNUFJ8=", false},
{
"ef0b8bad0be285099534277fde328f8f19b3be9cadcd4c08e6ac0b5f863745ac",
"This is a test message",
"H+zZagsyz7ioC/ZOa5EwsaKice0vs2BvZ0ljgkFHxD3vGsMlGeD4sXHEcfbI4h8lP29VitSBdf4A+nHXih7svf4=",
false,
},
{
"ef0b8bad0be285099534277fde328f8f19b3be9cadcd4c08e6ac0b5f863745ac",
"This is very very very very very very very very very very very very very very very very very" +
" very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very long message",
"IIIjej1rrUaPXYBPWVPjqyO29vbGCAA6SyMVGebk3nUjIypyRnJj58DSchfalVfkUZ+1VxRaKOx92TzC0I7UlKU=",
false,
},
{
"93596babb564cbbdc84f2370c710b9bcc94333495b60af719b5fcf9ba00ba82c",
"This is a test message",
"IIuDw09ffPgEDuxEw5yHVp1+mi4QpuhAwLyQdpMTfsHCOkMqTKXuP7dSNWMEJqZsiQ8eKMDRvf2wZ4e5bxcu4O0=",
false,
},
{
"50381cf8f52936faae4a05a073a03d688a9fa206d005e87a39da436c75476d78",
"This is a test message",
"ILBmbjCY2Z7eSXGXZoBI3x2ZRaYUYOGtEaDjXetaY+zNDtMOvagsOGEHnVT3f5kXlEbuvmPydHqLnyvZP3cDOWk=",
false,
},
{
"c7726663147afd1add392d129086e57c0b05aa66a6ded564433c04bd55741434",
"This is a test message",
"IOI207QUnTLr2Ll+s4kUxNgLgorkc/Z5Pc+XNvUBYLy2TxaU6oHEJ2TTJ1mZVrtUyHm6e315v1tIjeosW3Odfqw=",
false,
},
{
"c7726663147afd1add392d129086e57c0b05aa66a6ded564433c04bd55741434",
"1",
"IMcRFG1VNN9TDGXpCU+9CqKLNOuhwQiXI5hZpkTOuYHKBDOWayNuAABofYLqUHYTMiMf9mYFQ0sPgFJZz3F7ELQ=",
false,
},
{
"",
"This is a test message",
"",
true,
},
{
"0",
"This is a test message",
"",
true,
},
{
"0000000",
"This is a test message",
"",
true,
},
{
"c7726663147afd1add392d129086e57c0b",
"This is a test message",
"H6N+iPf23i2YkLsNzF/yyeBm9eSYBoY/HFV1Md1F0ElWBXW5E5mkdRtgjoRuq0yNb1CCFNWWlkn2gZknFJNUFJ8=",
false,
},
}

// Run tests
Expand Down
9 changes: 3 additions & 6 deletions verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,9 @@ func messageHash(message, header string) ([]byte, error) {
return nil, fmt.Errorf("long header is not supported")
}
messageLength := len(message)
/*
// @mrz testing with no limit to the size of the message
if messageLength >= 0xfd {
return nil, fmt.Errorf("long message is not supported")
}
*/
if messageLength >= 0xfd {
return nil, fmt.Errorf("long message is not supported")
}
bitcoinMsg := string([]byte{byte(headerLength)})
bitcoinMsg += header
bitcoinMsg += string([]byte{byte(messageLength)})
Expand Down
70 changes: 60 additions & 10 deletions verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,65 @@ func TestVerifyMessage(t *testing.T) {
inputData string
expectedError bool
}{
{"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ", "IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=", "Testing!", false},
{"", "IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=", "Testing!", true},
{"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ", "", "Testing!", true},
{"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ", "IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=", "", true},
{"0", "IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=", "Testing!", true},
{"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ", "GBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4naZ=", "Testing!", true},
{"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ", "GBD=", "Testing!", true},
{"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ", "GBse5w0f839t8wej8f2D=", "Testing!", true},
{
"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ",
"IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=",
"Testing!",
false,
},
{
"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ",
"IIIjej1rrUaPXYBPWVPjqyO29vbGCAA6SyMVGebk3nUjIypyRnJj58DSchfalVfkUZ+1VxRaKOx92TzC0I7UlKU=",
"This is very very very very very very very very very very very very very very very very very" +
" very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very very very very very very very very very very very very very " +
"very very very very very very very very long message",
true,
},
{
"",
"IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=",
"Testing!",
true,
},
{
"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ",
"",
"Testing!",
true,
},
{
"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ",
"IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=",
"",
true,
},
{
"0",
"IBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4na8=",
"Testing!",
true,
},
{
"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ",
"GBDscOd/Ov4yrd/YXantqajSAnW4fudpfr2KQy5GNo9pZybF12uNaal4KI822UpQLS/UJD+UK2SnNMn6Z3E4naZ=",
"Testing!",
true,
},
{
"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ",
"GBD=",
"Testing!",
true,
},
{
"1FiyJnrgwBc3Ff83V1yRWAkmXBdGrDQnXQ",
"GBse5w0f839t8wej8f2D=",
"Testing!",
true,
},
}

// Run tests
Expand Down Expand Up @@ -90,8 +141,7 @@ func TestVerifyMessageMessageHash(t *testing.T) {
{"", hBSV, "80e795d4a4caadd7047af389d9f7f220562feb6196032e2131e10563352c4bcc", false},
{"example message", "", "f91e1e5a01b6aad5ec785946e4233b0613bf6183ffde8da9879949cbf7d7ca57", false},
{"", "4qdD3HdK7SC4R9wTgfhr4QkNqRCKunbtRFlYPRYY6lGPiTbA9wZplnscnazyK0NMAx3KtvjDwWIX4J8djkSIYZaSNFEmztekNoe8NR0MLydp21U6Ayfm97oHelvTBcI5hQYccY45oI2KKEB1gyS0V6pbxoDtgjbCAGcnQvLB2iFykNcdU7A6Yntx812tKp90KilPADcEoKfkexMddqJ1pMz262MNhpTWmC4QOFMlB3xB5iTy2fxm6DgT3QLkiesk3kwM", "", true},
// @mrz - Disabled testing message length
// {"4qdD3HdK7SC4R9wTgfhr4QkNqRCKunbtRFlYPRYY6lGPiTbA9wZplnscnazyK0NMAx3KtvjDwWIX4J8djkSIYZaSNFEmztekNoe8NR0MLydp21U6Ayfm97oHelvTBcI5hQYccY45oI2KKEB1gyS0V6pbxoDtgjbCAGcnQvLB2iFykNcdU7A6Yntx812tKp90KilPADcEoKfkexMddqJ1pMz262MNhpTWmC4QOFMlB3xB5iTy2fxm6DgT3QLkiesk3kwM", "", "", true},
{"4qdD3HdK7SC4R9wTgfhr4QkNqRCKunbtRFlYPRYY6lGPiTbA9wZplnscnazyK0NMAx3KtvjDwWIX4J8djkSIYZaSNFEmztekNoe8NR0MLydp21U6Ayfm97oHelvTBcI5hQYccY45oI2KKEB1gyS0V6pbxoDtgjbCAGcnQvLB2iFykNcdU7A6Yntx812tKp90KilPADcEoKfkexMddqJ1pMz262MNhpTWmC4QOFMlB3xB5iTy2fxm6DgT3QLkiesk3kwM", "", "", true},
}

// Run tests
Expand Down

0 comments on commit 175891f

Please sign in to comment.