Created
July 23, 2020 09:21
-
-
Save ptsayli/35527f305a883b32a5a7fbbe9fb33698 to your computer and use it in GitHub Desktop.
test rlp-encoding
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
package main | |
import ( | |
"encoding/hex" | |
"fmt" | |
"github.com/maticnetwork/bor/rlp" | |
hmTypes "github.com/maticnetwork/heimdall/types" | |
) | |
func main() { | |
type receiptStruct struct { | |
Receipt []byte | |
} | |
output := "0xb902e6f902e3f851a0e047c7b78fac72b0b6183de3996e8d15839fb98646ffb1327da6a967e84aa69b80808080808080a08a0613cae02ed11426ac507df00a7b66c9481bf29dc86c4d13b0cfda7498b9318080808080808080f9028d31b90289f902860183014a07b9010000048000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000008020000000000000000000800000000000000000100000010001000000000000000000000000000000000000000000000800100000000000000020000000000000000000800000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000200020000000000000000010000000000000000000000000000000000000000000000000f9017bf89b9431074c34a757a4b9fc45169c58068f43b717b2d0f863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa00000000000000000000000007654bb30fc8e737f57d7347064069b819cd2e341a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000071afd498d0000f8dc9431074c34a757a4b9fc45169c58068f43b717b2d0f863a0ebff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4fa00000000000000000000000001d21d3ac4daf6d2416bc754560de47d1f6912b01a00000000000000000000000007654bb30fc8e737f57d7347064069b819cd2e341b86000000000000000000000000000000000000000000000000000071afd498d00000000000000000000000000000000000000000000000000001bac1c6f722100000000000000000000000000000000000000000000000000001ba5017228940000" | |
rawReceipt := "F851A0E047C7B78FAC72B0B6183DE3996E8D15839FB98646FFB1327DA6A967E84AA69B80808080808080A08A0613CAE02ED11426AC507DF00A7B66C9481BF29DC86C4D13B0CFDA7498B9318080808080808080F9028D31B90289F902860183014A07B9010000048000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000008020000000000000000000800000000000000000100000010001000000000000000000000000000000000000000000000800100000000000000020000000000000000000800000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000200020000000000000000010000000000000000000000000000000000000000000000000F9017BF89B9431074C34A757A4B9FC45169C58068F43B717B2D0F863A0DDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EFA00000000000000000000000007654BB30FC8E737F57D7347064069B819CD2E341A00000000000000000000000000000000000000000000000000000000000000000A000000000000000000000000000000000000000000000000000071AFD498D0000F8DC9431074C34A757A4B9FC45169C58068F43B717B2D0F863A0EBFF2602B3F468259E1E99F613FED6691F3A6526EFFE6EF3E768BA7AE7A36C4FA00000000000000000000000001D21D3AC4DAF6D2416BC754560DE47D1F6912B01A00000000000000000000000007654BB30FC8E737F57D7347064069B819CD2E341B86000000000000000000000000000000000000000000000000000071AFD498D00000000000000000000000000000000000000000000000000001BAC1C6F722100000000000000000000000000000000000000000000000000001BA5017228940000" | |
rawBytes, _ := hex.DecodeString(rawReceipt) | |
receipt := receiptStruct{rawBytes} | |
payload, _ := rlp.EncodeToBytes(receipt) | |
encodedData := hmTypes.BytesToHexBytes(payload) | |
fmt.Println("Expected Output Data", output) | |
fmt.Println("Actual Data", encodedData.String()) | |
fmt.Println("res", output == encodedData.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment