ChainSafe / ChainSafe/EthereumRPCSharp

EncodeList not working correctly

Open
#14 3 comments 0 reactions 0 assignees View on GitHub
Type: Bug
Dominant language
C#
Stars
3
Forks
1
PR merge metrics
No merged PRs in 30d

Description

**Context**
I'm trying to test that if a encode a list of values, I get the expected decoded value.

**Problem**
This is what I'm trying to achieve:
```
List byteArrayList = new List();

byte[] byte1 = HexByteConvertorExtensions.HexToByteArray("0x");
byte[] byte2 = HexByteConvertorExtensions.HexToByteArray("0x");
byte[] byte3 = HexByteConvertorExtensions.HexToByteArray("0x");

byteArrayList.Add(byte1);
byteArrayList.Add(byte2);
byteArrayList.Add(byte3);

byte[] expectedEncoded2 = HexByteConvertorExtensions.HexToByteArray("0xc3808080");


byte[] encoded = RLP.EncodeList(byteArrayList.ToArray());

// Assert
Assert.AreEqual(expectedEncoded2, encoded);
```

I send a list to encode and then I expect that the result is the expected one. For assertions I'm using the test data that ethersjs uses for their RLP tests (https://github.com/ethers-io/ethers.js/blob/main/src.ts/_tests/test-rlp.ts), for example:
Screenshot 2023-04-04 at 17 21 13

**Additional context**
I have this problem only with **EncodeList** method, because the method **EncodeElement** is working as expected.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.