Skip to content

Commit

Permalink
Merge pull request #142 from tonkeeper/test_inProgress_event
Browse files Browse the repository at this point in the history
create test event
  • Loading branch information
zakhar-petukhov committed Jul 17, 2023
2 parents 173f980 + 60c7a09 commit a60893b
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions pkg/api/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"errors"
"fmt"
"time"

"github.com/tonkeeper/opentonapi/pkg/bath"
"github.com/tonkeeper/opentonapi/pkg/core"
Expand All @@ -14,6 +15,7 @@ import (
"github.com/tonkeeper/tongo/boc"
"github.com/tonkeeper/tongo/tlb"
"github.com/tonkeeper/tongo/txemulator"
"golang.org/x/exp/slices"
)

func (h Handler) SendMessage(ctx context.Context, req oas.SendMessageReq) (r oas.SendMessageRes, _ error) {
Expand Down Expand Up @@ -103,6 +105,9 @@ func (h Handler) GetEventsByAccount(ctx context.Context, params oas.GetEventsByA
}
lastLT = trace.Lt
}
if account.ToRaw() == "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb" {
events = slices.Insert(events, 0, generateTestEvent())
}
return &oas.AccountEvents{Events: events, NextFrom: int64(lastLT)}, nil
}

Expand Down Expand Up @@ -311,3 +316,56 @@ func emulatedTreeToTrace(tree *txemulator.TxTree, accounts map[tongo.AccountID]t
}
return t, nil
}

func generateTestEvent() oas.AccountEvent {
return oas.AccountEvent{
EventID: "a96d84940781cc29d3fb890384d35ba49cdd9d891a123a9f90939ddb57b09fc2",
Account: oas.AccountAddress{
Address: "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
IsScam: false,
},
Timestamp: time.Now().Unix(),
IsScam: false,
Lt: int64(39228825000001),
InProgress: true,
Extra: -5825767,
Actions: []oas.Action{
{
Type: oas.ActionTypeTonTransfer,
Status: oas.ActionStatusOk,
TonTransfer: oas.OptTonTransferAction{
Set: true,
Value: oas.TonTransferAction{
Sender: oas.AccountAddress{
Address: "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
IsScam: false,
},
Recipient: oas.AccountAddress{
Address: "0:e9a07c65998cd537d6ac2c4c9ddd73a299295527101328c87358508ccbf868fa",
IsScam: false,
},
Amount: 10_000_000_000,
},
},
SimplePreview: oas.ActionSimplePreview{
Name: "Ton Transfer",
Description: "Transferring 10_000_000_000 TON",
Value: oas.OptString{
Set: true,
Value: "10_000_000_000 TON",
},
Accounts: []oas.AccountAddress{
{
Address: "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
IsScam: false,
},
{
Address: "0:e9a07c65998cd537d6ac2c4c9ddd73a299295527101328c87358508ccbf868fa",
IsScam: false,
},
},
},
},
},
}
}

0 comments on commit a60893b

Please sign in to comment.