Skip to content

Commit

Permalink
notification available in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Feb 15, 2023
1 parent cd52b74 commit 27de7f3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Fairy.Tester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,17 @@ private JObject GetInvokeResultWithSession(string session, bool writeSnapshot, b

JObject json = new();

JArray notifications = new();
for (int i = newEngine.Notifications.Count - 1; i >= 0; i--)
{
NotifyEventArgs notification = newEngine.Notifications[i];
JObject notificationJson = new();
notificationJson["tx"] = notification.ScriptContainer.Hash.ToString();
notificationJson["scripthash"] = notification.ScriptHash.ToString();
notificationJson["contractname"] = NativeContract.ContractManagement.GetContract(newEngine.Snapshot, notification.ScriptHash)?.Manifest.Name;
notificationJson["eventname"] = notification.EventName;
notificationJson["eventargs"] = notification.State.ToJson();
notifications.Add(notificationJson);
if(newEngine.Notifications[i].EventName == "OracleRequest")
{
int oracleContractId = NativeContract.Oracle.Id;
Expand All @@ -132,6 +141,7 @@ private JObject GetInvokeResultWithSession(string session, bool writeSnapshot, b
oracleRequests.Add(oracleRequest.ToStackItem(new ReferenceCounter()).ToJson());
}
}
if (notifications.Count > 0) json["notifications"] = notifications;

json["script"] = Convert.ToBase64String(script);
json["state"] = newEngine.State;
Expand Down

0 comments on commit 27de7f3

Please sign in to comment.