Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions dotnet/EcencyApi.Tests/WalletActionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Text.Json.Nodes;
using EcencyApi.Handlers;
using Xunit;

namespace EcencyApi.Tests;

/// <summary>
/// The token action ids are a client-facing contract: web and mobile map them to
/// concrete wallet operations, and an id neither client recognizes either renders
/// nothing (web drops unknown ids) or renders an unlabeled control (mobile passes
/// them through). Pin the ids and their order.
/// </summary>
public class WalletActionsTests
{
private static string[] Ids(JsonArray actions) =>
actions.Select(a => a!["id"]!.GetValue<string>()).ToArray();

[Fact]
public void HpActions_AreTheChainOperationNamesInRenderOrder()
{
Assert.Equal(
new[] { "delegate_vesting_shares", "withdraw_vesting", "set_withdraw_vesting_route" },
Ids(WalletApi.HpActions()));
}

[Fact]
public void HiveActions_OnlyOfferSavingsWithdrawalWhenSavingsExist()
{
Assert.DoesNotContain("transfer_from_savings", Ids(WalletApi.BuildHiveActions(0)));
Assert.Contains("transfer_from_savings", Ids(WalletApi.BuildHiveActions(1.5)));
}

[Fact]
public void HbdActions_OnlyOfferSavingsWithdrawalWhenSavingsExist()
{
Assert.DoesNotContain("transfer_from_savings", Ids(WalletApi.BuildHbdActions(0)));
Assert.Contains("transfer_from_savings", Ids(WalletApi.BuildHbdActions(1.5)));
}
}
5 changes: 4 additions & 1 deletion dotnet/EcencyApi/Handlers/WalletApi.Market.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ internal static JsonArray BuildHiveActions(double savings)
return Actions(ids.ToArray());
}

internal static JsonArray HpActions() => Actions("delegate_vesting_shares", "withdraw_vesting");
// set_withdraw_vesting_route lets clients link straight to the withdraw routes UI.
// Deliberately added after the original two ids: clients render actions in order.
internal static JsonArray HpActions() =>
Actions("delegate_vesting_shares", "withdraw_vesting", "set_withdraw_vesting_route");

internal static JsonArray BuildHbdActions(double savings)
{
Expand Down
4 changes: 4 additions & 0 deletions dotnet/parity/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ def norm_body(text):
"Same request-delete rerouting as ::min.",
"/private-api/request-delete::badcode":
"Same request-delete rerouting as ::min.",
"/wallet-api/portfolio-v2::pop":
"The HP action list gained set_withdraw_vesting_route so clients can link "
"straight to the withdraw routes UI; the reference build emits only "
"delegate_vesting_shares and withdraw_vesting.",
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep parity checks for the rest of portfolio-v2

When the differential harness compares the populated /wallet-api/portfolio-v2 case, adding it to KNOWN_DIVERGENCES causes the loop to continue before checking even the status, content type, or any unrelated response fields. Consequently, regressions anywhere in this large aggregation endpoint now produce a clean parity run. Normalize or specially compare only the added HP action instead of exempting the entire case.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid, fixed in 7633c76 by removing the entry rather than narrowing it.

Confirmed the mechanism: KNOWN_DIVERGENCES hits continue before any comparison, so it would have skipped status and content-type too, not just the body.

Went further than narrowing the comparison because this case can never be body-compared anyway. norm_body only parses JSON, it does no nondeterminism smoothing, and portfolio-v2 balances and APR move every block, so the case already lands in loose on a run-vs-run diff. loose skips only the body and still checks status and content-type, which is strictly better than what my entry did. The exemption was therefore redundant on the body and harmful on everything else.

Left a comment in its place explaining why the case is deliberately absent, so the next person does not re-add it.

}


Expand Down
Loading