Skip to content

Commit

Permalink
rounding up to 1024 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
igormcoelho committed Aug 15, 2019
1 parent dc84504 commit 7d516be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions neo.UnitTests/Network/P2P/Payloads/UT_Witness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ private Witness PrepareDummyWitness(int maxAccounts)
[TestMethod]
public void MaxSize_OK()
{
var witness = PrepareDummyWitness(14);
var witness = PrepareDummyWitness(10);

// Check max size

Assert.IsTrue(witness.Size < 1400);
witness.Size.Should().Be(1003);
witness.InvocationScript.GetVarSize().Should().Be(653);
witness.VerificationScript.GetVarSize().Should().Be(350);

Assert.IsTrue(witness.Size <= 1024);

var copy = witness.ToArray().AsSerializable<Witness>();

Expand Down
10 changes: 5 additions & 5 deletions neo/Network/P2P/Payloads/Witness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public virtual UInt160 ScriptHash

void ISerializable.Deserialize(BinaryReader reader)
{
// This is designed to allow a MultiSig 10/10 (around 1000 bytes)
// Invocation = 10 * 64 + 10 = 650
InvocationScript = reader.ReadVarBytes(650);
// Verification = 10 * 33 = 330 ~ 350
VerificationScript = reader.ReadVarBytes(350);
// This is designed to allow a MultiSig 10/10 (around 1003 bytes) ~1024 bytes
// Invocation = 10 * 64 + 10 = 650 ~ 664 (exact is 653)
InvocationScript = reader.ReadVarBytes(664);
// Verification = 10 * 33 + 10 = 340 ~ 360 (exact is 350)
VerificationScript = reader.ReadVarBytes(360);
}

void ISerializable.Serialize(BinaryWriter writer)
Expand Down

0 comments on commit 7d516be

Please sign in to comment.