Skip to content

Commit

Permalink
Merge pull request #148 from tonkeeper/encrypted-comment-test
Browse files Browse the repository at this point in the history
Add test for extracting TonTransfer with encrypted comment from trace
  • Loading branch information
mr-tron committed Jul 21, 2023
2 parents 8fafaee + cc38b1c commit 1c32333
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/api/testdata/jetton-balances.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"jetton": {
"address": "0:beb5d4638e860ccf7317296e298fde5b35982f4725b0676dc98b1de987b82ebc",
"name": "Jetton kingy",
"name": "KINGYTON",
"symbol": "KINGY",
"decimals": 9,
"image": "https://i.ibb.co/FbTCKRP/logotokenkingy.png",
Expand Down
7 changes: 7 additions & 0 deletions pkg/bath/bath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ func TestFindActions(t *testing.T) {
tongo.MustParseBlockID("(0,8000000000000000,32606229)"),
tongo.MustParseBlockID("(-1,8000000000000000,27037607)"),
tongo.MustParseBlockID("(0,8000000000000000,32606232)"),
// encrypted comment
tongo.MustParseBlockID("(0,8000000000000000,36828763)"),
}),
)

Expand Down Expand Up @@ -224,6 +226,11 @@ func TestFindActions(t *testing.T) {
hash: "32467cfe9b9faecf6cd2a8055bfc7243e289fec6b2f479df2bcbf78eac9826a0",
filenamePrefix: "deploy-contract-failed",
},
{
name: "encrypted comment",
hash: "6f3e1f2c05df05345198a9d26456dcb51d4c78ce64ced56fb9976e92941211d3",
filenamePrefix: "encrypted-comment",
},
} {
t.Run(c.name, func(t *testing.T) {
trace, err := storage.GetTrace(context.Background(), tongo.MustParseHash(c.hash))
Expand Down
4 changes: 2 additions & 2 deletions pkg/bath/straws.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ func (b BubbleJettonTransfer) ToAction() (action *Action) {
}
switch c := b.payload.(type) {
case string:
a.NftItemTransfer.Comment = &c
a.JettonTransfer.Comment = &c
case EncryptedComment:
a.NftItemTransfer.EncryptedComment = &c
a.JettonTransfer.EncryptedComment = &c
}
return &a
}
2 changes: 2 additions & 0 deletions pkg/bath/testdata/deploy-contract-failed.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"TonTransfer": {
"Amount": 100000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "-1:def630230329e2961dd105feb015f8169fda5189e3a0e7a43bc5cabc9821b0c1",
"Sender": "0:2a51f944720857a9dc3a62097a7ba94f12ff91a8e4c6c0bcc6c169845667082d",
"Refund": null
Expand All @@ -23,6 +24,7 @@
"TonTransfer": {
"Amount": 85940000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:2a51f944720857a9dc3a62097a7ba94f12ff91a8e4c6c0bcc6c169845667082d",
"Sender": "-1:def630230329e2961dd105feb015f8169fda5189e3a0e7a43bc5cabc9821b0c1",
"Refund": null
Expand Down
1 change: 1 addition & 0 deletions pkg/bath/testdata/deploy-contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"TonTransfer": {
"Amount": 5993073999,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
"Sender": "0:e351d7af505bbae196ea434b13db91adcdffc5063ff2d7b9f0f76139b3c7b99a",
"Refund": null
Expand Down
3 changes: 3 additions & 0 deletions pkg/bath/testdata/disintar-nft-purchase.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"TonTransfer": {
"Amount": 14250000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:bbf8ca0967809097d1aa67afee9cb2db2b9aa5e5f66c50a5c92033dc57b1cc23",
"Sender": "0:82e5172540cc7b9aeb8dfa6a82c2053f7008f484f94472efa369a9628a8c896a",
"Refund": null
Expand All @@ -26,6 +27,7 @@
"TonTransfer": {
"Amount": 750000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:bbf8ca0967809097d1aa67afee9cb2db2b9aa5e5f66c50a5c92033dc57b1cc23",
"Sender": "0:82e5172540cc7b9aeb8dfa6a82c2053f7008f484f94472efa369a9628a8c896a",
"Refund": null
Expand All @@ -37,6 +39,7 @@
"TonTransfer": {
"Amount": 750000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:eb2eaf97ea32993470127208218748758a88374ad2bbd739fc75c9ab3a3f233d",
"Sender": "0:82e5172540cc7b9aeb8dfa6a82c2053f7008f484f94472efa369a9628a8c896a",
"Refund": null
Expand Down
41 changes: 41 additions & 0 deletions pkg/bath/testdata/encrypted-comment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"Actions": [
{
"ContractDeploy": {
"Address": "0:2fb4262a611b95947a547046f778062257949be65667fb405ad881e44a5d05dc",
"Interfaces": null
},
"Success": true,
"Type": "ContractDeploy"
},
{
"TonTransfer": {
"Amount": 50000000,
"Comment": null,
"EncryptedComment": {
"EncryptionType": "simple",
"CipherText": "aJBgw9zGhJ/6SLEdKfRqo5geM2jJdNKrBLLTSKH8ujSgJemI94cEt5IVsvg3NJZZL9nNhrUPDV7ArMlY+mb60eOBVOwg9ByvkznT3irTdjU="
},
"Recipient": "0:2ef03249b71e92d548a4481e0ee4b399eaee32a8099ee398a1ca7965697ac3fd",
"Sender": "0:2fb4262a611b95947a547046f778062257949be65667fb405ad881e44a5d05dc",
"Refund": null
},
"Success": true,
"Type": "TonTransfer"
}
],
"Accounts": [
{
"Account": "0:2ef03249b71e92d548a4481e0ee4b399eaee32a8099ee398a1ca7965697ac3fd",
"Ton": 50000000,
"Fee": 991039,
"Jettons": null
},
{
"Account": "0:2fb4262a611b95947a547046f778062257949be65667fb405ad881e44a5d05dc",
"Ton": -50000000,
"Fee": 8255002,
"Jettons": null
}
]
}
3 changes: 3 additions & 0 deletions pkg/bath/testdata/getgems-nft-purchase.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"TonTransfer": {
"Amount": 687432978,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:353d4cb749da429dbee9387ff7f65c0d99a922396a3d239eff8be465422771a0",
"Sender": "0:4495a1921ab497b0eacee0d78838f8aeaba12481c29ec592c7fd5cbdd5b5ad0e",
"Refund": null
Expand All @@ -34,6 +35,7 @@
"TonTransfer": {
"Amount": 80000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:353d4cb749da429dbee9387ff7f65c0d99a922396a3d239eff8be465422771a0",
"Sender": "0:4495a1921ab497b0eacee0d78838f8aeaba12481c29ec592c7fd5cbdd5b5ad0e",
"Refund": null
Expand All @@ -45,6 +47,7 @@
"TonTransfer": {
"Amount": 40000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:a3935861f79daf59a13d6d182e1640210c02f98e3df18fda74b8f5ab141abf18",
"Sender": "0:4495a1921ab497b0eacee0d78838f8aeaba12481c29ec592c7fd5cbdd5b5ad0e",
"Refund": null
Expand Down
1 change: 1 addition & 0 deletions pkg/bath/testdata/jetton-transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"JettonTransfer": {
"Comment": "",
"EncryptedComment": null,
"Jetton": "0:0871bd56a8daf413bace5e03b471b01942755b4b4ea6807daf801bed044ea9d1",
"Recipient": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
"Sender": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
Expand Down
1 change: 1 addition & 0 deletions pkg/bath/testdata/nft-transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"NftItemTransfer": {
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
"Sender": "0:49a43c76745b520241ebf00301e1bcb729e38dff9180d1f0bfac16245a58c52e",
"Nft": "0:513828e5a7a6523625195da4490ef08ee0e0327a4c328fac06935ebcc48294fd",
Expand Down
1 change: 1 addition & 0 deletions pkg/bath/testdata/simple-transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"TonTransfer": {
"Amount": 7570000000,
"Comment": "Telegram Premium for 6 months \n\nRef#FHJAZvYc",
"EncryptedComment": null,
"Recipient": "0:408da3b28b6c065a593e10391269baaa9c5f8caebc0c69d9f0aabbab2a99256b",
"Sender": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
"Refund": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"TonTransfer": {
"Amount": 9999990000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:d0a9dc6bb3bfcce8c99dcfb025b36f550784e4f6a62c80a839b81601a202950d",
"Sender": "-1:be0454b023bb0d84ba3bf0f874b4da9d77af1d146a2aa467492bf3d05d22d434",
"Refund": null
Expand Down

0 comments on commit 1c32333

Please sign in to comment.