Skip to content

Commit

Permalink
Merge pull request #2222 from greymistcube/refactor/remove-rehearsal
Browse files Browse the repository at this point in the history
🧹 Cleanup rehearsal related code.
  • Loading branch information
greymistcube authored Nov 13, 2023
2 parents 485fef4 + ccf07b9 commit 63df50b
Show file tree
Hide file tree
Showing 317 changed files with 2 additions and 5,264 deletions.
26 changes: 0 additions & 26 deletions .Lib9c.Tests/Action/ActivateAccount0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,6 @@ public void Execute()
activatedAccounts.Accounts);
}

[Fact]
public void Rehearsal()
{
var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 };
var privateKey = new PrivateKey();
(ActivationKey activationKey, PendingActivationState pendingActivation) =
ActivationKey.Create(privateKey, nonce);

ActivateAccount0 action = activationKey.CreateActivateAccount0(nonce);
IAccount nextState = action.Execute(new ActionContext()
{
PreviousState = new Account(MockState.Empty),
Signer = default,
Rehearsal = true,
BlockIndex = 1,
});

Assert.Equal(
ImmutableHashSet.Create(
ActivatedAccountsState.Address,
pendingActivation.address
),
nextState.Delta.UpdatedAddresses
);
}

[Fact]
public void ExecuteWithInvalidSignature()
{
Expand Down
27 changes: 0 additions & 27 deletions .Lib9c.Tests/Action/ActivateAccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,6 @@ public void Execute(bool invalid, bool pendingExist, bool alreadyActivated, Type
}
}

[Fact]
public void Rehearsal()
{
var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 };
var privateKey = new PrivateKey();
(ActivationKey activationKey, PendingActivationState pendingActivation) =
ActivationKey.Create(privateKey, nonce);

ActivateAccount action = activationKey.CreateActivateAccount(nonce);
Address activatedAddress = default(Address).Derive(ActivationKey.DeriveKey);
IAccount nextState = action.Execute(new ActionContext()
{
PreviousState = new Account(MockState.Empty),
Signer = default,
Rehearsal = true,
BlockIndex = 1,
});

Assert.Equal(
ImmutableHashSet.Create(
activatedAddress,
pendingActivation.address
),
nextState.Delta.UpdatedAddresses
);
}

[Fact]
public void PlainValue()
{
Expand Down
29 changes: 0 additions & 29 deletions .Lib9c.Tests/Action/AddActivatedAccount0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,6 @@ public void Execute()
);
}

[Fact]
public void Rehearsal()
{
var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7");
var state = new Account(
MockState.Empty
.SetState(AdminState.Address, new AdminState(admin, 100).Serialize())
.SetState(ActivatedAccountsState.Address, new ActivatedAccountsState().Serialize()));
var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730");
var action = new AddActivatedAccount0(newComer);

IAccount nextState = action.Execute(new ActionContext()
{
BlockIndex = 1,
Miner = default,
PreviousState = state,
Signer = admin,
Rehearsal = true,
});

Assert.Equal(
new[]
{
ActivatedAccountsState.Address,
}.ToImmutableHashSet(),
nextState.Delta.UpdatedAddresses
);
}

[Fact]
public void ExecuteWithNonExistsAccounts()
{
Expand Down
28 changes: 0 additions & 28 deletions .Lib9c.Tests/Action/AddActivatedAccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,6 @@ public void Execute(bool isAdmin, long blockIndex, bool alreadyActivated, Type e
}
}

[Fact]
public void Rehearsal()
{
var admin = new Address("8d9f76aF8Dc5A812aCeA15d8bf56E2F790F47fd7");
var state = new Account(
MockState.Empty
.SetState(AdminState.Address, new AdminState(admin, 100).Serialize()));
var newComer = new Address("399bddF9F7B6d902ea27037B907B2486C9910730");
var action = new AddActivatedAccount(newComer);

IAccount nextState = action.Execute(new ActionContext()
{
BlockIndex = 1,
Miner = default,
PreviousState = state,
Signer = admin,
Rehearsal = true,
});

Assert.Equal(
new[]
{
newComer.Derive(ActivationKey.DeriveKey),
}.ToImmutableHashSet(),
nextState.Delta.UpdatedAddresses
);
}

[Fact]
public void PlainValue()
{
Expand Down
49 changes: 0 additions & 49 deletions .Lib9c.Tests/Action/Buy10Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,55 +768,6 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList)
}
}

[Fact]
public void Rehearsal()
{
PurchaseInfo purchaseInfo = new PurchaseInfo(
_orderId,
default,
_sellerAgentAddress,
_sellerAvatarAddress,
ItemSubType.Weapon,
new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0)
);

var action = new Buy10
{
buyerAvatarAddress = _buyerAvatarAddress,
purchaseInfos = new[] { purchaseInfo },
};

var updatedAddresses = new List<Address>()
{
_sellerAgentAddress,
_sellerAvatarAddress,
_sellerAvatarAddress.Derive(LegacyInventoryKey),
_sellerAvatarAddress.Derive(LegacyWorldInformationKey),
_sellerAvatarAddress.Derive(LegacyQuestListKey),
OrderDigestListState.DeriveAddress(_sellerAvatarAddress),
_buyerAgentAddress,
_buyerAvatarAddress,
_buyerAvatarAddress.Derive(LegacyInventoryKey),
_buyerAvatarAddress.Derive(LegacyWorldInformationKey),
_buyerAvatarAddress.Derive(LegacyQuestListKey),
Addresses.GoldCurrency,
ShardedShopStateV2.DeriveAddress(ItemSubType.Weapon, _orderId),
OrderReceipt.DeriveAddress(_orderId),
};

var state = new Account(MockState.Empty);

var nextState = action.Execute(new ActionContext()
{
PreviousState = state,
Signer = _buyerAgentAddress,
BlockIndex = 0,
Rehearsal = true,
});

Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses);
}

[Fact]
public void Execute_With_Testbed()
{
Expand Down
49 changes: 0 additions & 49 deletions .Lib9c.Tests/Action/Buy11Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -774,55 +774,6 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList)
}
}

[Fact]
public void Rehearsal()
{
PurchaseInfo purchaseInfo = new PurchaseInfo(
_orderId,
default,
_sellerAgentAddress,
_sellerAvatarAddress,
ItemSubType.Weapon,
new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0)
);

var action = new Buy11
{
buyerAvatarAddress = _buyerAvatarAddress,
purchaseInfos = new[] { purchaseInfo },
};

var updatedAddresses = new List<Address>()
{
_sellerAgentAddress,
_sellerAvatarAddress,
_sellerAvatarAddress.Derive(LegacyInventoryKey),
_sellerAvatarAddress.Derive(LegacyWorldInformationKey),
_sellerAvatarAddress.Derive(LegacyQuestListKey),
OrderDigestListState.DeriveAddress(_sellerAvatarAddress),
_buyerAgentAddress,
_buyerAvatarAddress,
_buyerAvatarAddress.Derive(LegacyInventoryKey),
_buyerAvatarAddress.Derive(LegacyWorldInformationKey),
_buyerAvatarAddress.Derive(LegacyQuestListKey),
Buy11.GetFeeStoreAddress(),
ShardedShopStateV2.DeriveAddress(ItemSubType.Weapon, _orderId),
OrderReceipt.DeriveAddress(_orderId),
};

var state = new Account(MockState.Empty);

var nextState = action.Execute(new ActionContext()
{
PreviousState = state,
Signer = _buyerAgentAddress,
BlockIndex = 0,
Rehearsal = true,
});

Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses);
}

[Fact]
public void Execute_With_Testbed()
{
Expand Down
49 changes: 0 additions & 49 deletions .Lib9c.Tests/Action/Buy8Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,55 +550,6 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember)
}
}

[Fact]
public void Rehearsal()
{
PurchaseInfo purchaseInfo = new PurchaseInfo(
_orderId,
default,
_sellerAgentAddress,
_sellerAvatarAddress,
ItemSubType.Weapon,
new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0)
);

var action = new Buy8
{
buyerAvatarAddress = _buyerAvatarAddress,
purchaseInfos = new[] { purchaseInfo },
};

var updatedAddresses = new List<Address>()
{
_sellerAgentAddress,
_sellerAvatarAddress,
_sellerAvatarAddress.Derive(LegacyInventoryKey),
_sellerAvatarAddress.Derive(LegacyWorldInformationKey),
_sellerAvatarAddress.Derive(LegacyQuestListKey),
OrderDigestListState.DeriveAddress(_sellerAvatarAddress),
_buyerAgentAddress,
_buyerAvatarAddress,
_buyerAvatarAddress.Derive(LegacyInventoryKey),
_buyerAvatarAddress.Derive(LegacyWorldInformationKey),
_buyerAvatarAddress.Derive(LegacyQuestListKey),
Addresses.GoldCurrency,
ShardedShopStateV2.DeriveAddress(ItemSubType.Weapon, _orderId),
OrderReceipt.DeriveAddress(_orderId),
};

var state = new Account(MockState.Empty);

var nextState = action.Execute(new ActionContext()
{
PreviousState = state,
Signer = _buyerAgentAddress,
BlockIndex = 0,
Rehearsal = true,
});

Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses);
}

private (AvatarState AvatarState, AgentState AgentState) CreateAvatarState(
Address agentAddress, Address avatarAddress)
{
Expand Down
49 changes: 0 additions & 49 deletions .Lib9c.Tests/Action/Buy9Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,55 +649,6 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember)
}
}

[Fact]
public void Rehearsal()
{
PurchaseInfo purchaseInfo = new PurchaseInfo(
_orderId,
default,
_sellerAgentAddress,
_sellerAvatarAddress,
ItemSubType.Weapon,
new FungibleAssetValue(_goldCurrencyState.Currency, 10, 0)
);

var action = new Buy9
{
buyerAvatarAddress = _buyerAvatarAddress,
purchaseInfos = new[] { purchaseInfo },
};

var updatedAddresses = new List<Address>()
{
_sellerAgentAddress,
_sellerAvatarAddress,
_sellerAvatarAddress.Derive(LegacyInventoryKey),
_sellerAvatarAddress.Derive(LegacyWorldInformationKey),
_sellerAvatarAddress.Derive(LegacyQuestListKey),
OrderDigestListState.DeriveAddress(_sellerAvatarAddress),
_buyerAgentAddress,
_buyerAvatarAddress,
_buyerAvatarAddress.Derive(LegacyInventoryKey),
_buyerAvatarAddress.Derive(LegacyWorldInformationKey),
_buyerAvatarAddress.Derive(LegacyQuestListKey),
Addresses.GoldCurrency,
ShardedShopStateV2.DeriveAddress(ItemSubType.Weapon, _orderId),
OrderReceipt.DeriveAddress(_orderId),
};

var state = new Account(MockState.Empty);

var nextState = action.Execute(new ActionContext()
{
PreviousState = state,
Signer = _buyerAgentAddress,
BlockIndex = 0,
Rehearsal = true,
});

Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses);
}

private (AvatarState AvatarState, AgentState AgentState) CreateAvatarState(
Address agentAddress, Address avatarAddress)
{
Expand Down
31 changes: 0 additions & 31 deletions .Lib9c.Tests/Action/ClaimMonsterCollectionReward2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,37 +200,6 @@ public void Execute_Throw_RequiredBlockIndexException()
);
}

[Fact]
public void Rehearsal()
{
ClaimMonsterCollectionReward2 action = new ClaimMonsterCollectionReward2
{
avatarAddress = _avatarAddress,
};

IAccount nextState = action.Execute(new ActionContext
{
PreviousState = new Account(MockState.Empty),
Signer = _signer,
BlockIndex = 0,
Rehearsal = true,
}
);

List<Address> updatedAddresses = new List<Address>
{
_avatarAddress,
_avatarAddress.Derive(LegacyInventoryKey),
_avatarAddress.Derive(LegacyWorldInformationKey),
_avatarAddress.Derive(LegacyQuestListKey),
MonsterCollectionState.DeriveAddress(_signer, 0),
MonsterCollectionState.DeriveAddress(_signer, 1),
MonsterCollectionState.DeriveAddress(_signer, 2),
MonsterCollectionState.DeriveAddress(_signer, 3),
};
Assert.Equal(updatedAddresses.ToImmutableHashSet(), nextState.Delta.UpdatedAddresses);
}

private class ExecuteFixture : IEnumerable<object[]>
{
private readonly List<object[]> _data = new List<object[]>
Expand Down
Loading

0 comments on commit 63df50b

Please sign in to comment.