Skip to content

Commit

Permalink
chore: Remove warnings from test code
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Dec 26, 2024
1 parent 5895f94 commit 1d78c30
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ private static void Execute(
RandomSeed = 0,
BlockIndex = blockIndex,
});
var agent = nextStates.GetAgentState(agentAddr);
var agent = nextStates.GetAgentState(agentAddr)!;
Assert.Single(agent.avatarAddresses);
Assert.True(agent.avatarAddresses.ContainsKey(action.AvatarIndex));
avatarAddr ??= agent.avatarAddresses[action.AvatarIndex];
Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ManipulateStateTest
private static readonly Address AdminAddr = new PrivateKey().Address;

// See also InitializeUtil.cs
private static readonly Currency Ncg = Currency.Legacy(
private static readonly Currency Ncg = Currency.Uncapped(
"NCG",
2,
null
Expand Down Expand Up @@ -187,7 +187,7 @@ public static IEnumerable<object[]> FetchWorldInfo()

yield return new object[]
{
tableSheets.WorldSheet.OrderedList.Last(world => world.Id < 100).StageEnd,
tableSheets.WorldSheet.OrderedList!.Last(world => world.Id < 100).StageEnd,
new WorldInformation(0L, worldSheet, true),
};
}
Expand Down Expand Up @@ -421,7 +421,7 @@ private void TestAvatarState(

private void TestInventoryState(IWorld state, Inventory targetInventory)
{
var inventoryState = new Inventory((List)state.GetAccount(Addresses.Inventory).GetState(_avatarAddress));
var inventoryState = new Inventory((List)state.GetAccount(Addresses.Inventory).GetState(_avatarAddress)!);
Assert.Equal(targetInventory.Items.Count, inventoryState.Items.Count);
foreach (var item in targetInventory.Items)
{
Expand Down
27 changes: 22 additions & 5 deletions .Lib9c.Miner.Tests/CustomActionsDeserializableValidatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,24 @@ public IWorld Execute(IActionContext context)

private class MockTransaction : ITransaction
{
private IImmutableSet<Address>? _updatedAddresses;
private PublicKey? _publicKey;
private byte[]? _signature;

public long Nonce { get; init; }
public Address Signer { get; init; }
public IImmutableSet<Address> UpdatedAddresses { get; init; }
public IImmutableSet<Address> UpdatedAddresses
{
get => _updatedAddresses
?? throw new InvalidOperationException("UpdatedAddresses is not set.");
init => _updatedAddresses = value;
}
public DateTimeOffset Timestamp { get; init; }
public PublicKey PublicKey { get; init; }
public PublicKey PublicKey
{
get => _publicKey ?? throw new InvalidOperationException("PublicKey is not set.");
init => _publicKey = value;
}
public BlockHash? GenesisHash { get; init; }
public TxActionList Actions =>
new(SystemAction is { } sa ? new IValue[]{ sa } : CustomActions!);
Expand All @@ -70,20 +83,24 @@ private class MockTransaction : ITransaction
public long? GasLimit => null;

public TxId Id { get; init; }
public byte[] Signature { get; init; }
public byte[] Signature
{
get => _signature ?? throw new InvalidOperationException("Signature is not set.");
init => _signature = value;
}
public IValue? SystemAction { get; init; }
public IImmutableList<IValue>? CustomActions { get; init; }
public bool Equals(ITxInvoice? other)
{
return UpdatedAddresses.Equals(other.UpdatedAddresses) &&
return UpdatedAddresses.Equals(other?.UpdatedAddresses) &&
Timestamp.Equals(other.Timestamp) &&
Nullable.Equals(GenesisHash, other.GenesisHash) &&
Actions.Equals(other.Actions);
}

public bool Equals(ITxSigningMetadata? other)
{
return Nonce == other.Nonce &&
return Nonce == other?.Nonce &&
Signer.Equals(other.Signer) &&
PublicKey.Equals(other.PublicKey);
}
Expand Down

0 comments on commit 1d78c30

Please sign in to comment.