-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
270 changed files
with
10,736 additions
and
1,749 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/Nethermind/Nethermind.Abi.Test/AbiEncoderExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2018 Demerzel Solutions Limited | ||
* This file is part of the Nethermind library. | ||
* | ||
* The Nethermind library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Nethermind library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with the Nethermind. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
using NSubstitute; | ||
using NUnit.Framework; | ||
|
||
namespace Nethermind.Abi.Test | ||
{ | ||
public class AbiEncoderExtensionsTests | ||
{ | ||
[Test] | ||
public void Encode_should_be_called() | ||
{ | ||
var abi = Substitute.For<IAbiEncoder>(); | ||
var parameters = new object[] {"p1"}; | ||
var abiSignature = new AbiSignature("test", AbiType.String); | ||
var abiEncodingStyle = AbiEncodingStyle.Packed; | ||
|
||
abi.Encode(new AbiEncodingInfo(abiEncodingStyle, abiSignature), parameters); | ||
abi.Received().Encode(abiEncodingStyle, abiSignature, parameters); | ||
} | ||
|
||
[Test] | ||
public void Dencode_should_be_called() | ||
{ | ||
var abi = Substitute.For<IAbiEncoder>(); | ||
var data = new byte[] {100, 200}; | ||
var abiSignature = new AbiSignature("test", AbiType.String); | ||
var abiEncodingStyle = AbiEncodingStyle.Packed; | ||
|
||
abi.Decode(new AbiEncodingInfo(abiEncodingStyle, abiSignature), data); | ||
abi.Received().Decode(abiEncodingStyle, abiSignature, data); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2018 Demerzel Solutions Limited | ||
* This file is part of the Nethermind library. | ||
* | ||
* The Nethermind library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Nethermind library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with the Nethermind. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace Nethermind.Abi | ||
{ | ||
public static class AbiEncoderExtensions | ||
{ | ||
public static byte[] Encode(this IAbiEncoder encoder, AbiEncodingInfo abiEncodingInfo, params object[] arguments) | ||
=> encoder.Encode(abiEncodingInfo.EncodingStyle, abiEncodingInfo.Signature, arguments); | ||
|
||
public static object[] Decode(this IAbiEncoder encoder, AbiEncodingInfo abiEncodingInfo, byte[] data) | ||
=> encoder.Decode(abiEncodingInfo.EncodingStyle, abiEncodingInfo.Signature, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2018 Demerzel Solutions Limited | ||
* This file is part of the Nethermind library. | ||
* | ||
* The Nethermind library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Nethermind library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with the Nethermind. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace Nethermind.Abi | ||
{ | ||
public class AbiEncodingInfo | ||
{ | ||
public AbiEncodingStyle EncodingStyle { get; } | ||
public AbiSignature Signature { get; } | ||
|
||
public AbiEncodingInfo(AbiEncodingStyle encodingStyle, AbiSignature signature) | ||
{ | ||
EncodingStyle = encodingStyle; | ||
Signature = signature; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.