-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from dahlia/store-indices
Adjust how IStore deals with state references and tx nonce
- Loading branch information
Showing
13 changed files
with
372 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"editor.rulers": [80] | ||
"editor.rulers": [80, 100] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using Libplanet.Blocks; | ||
using Libplanet.Tests.Common.Action; | ||
using Libplanet.Tx; | ||
using Xunit; | ||
|
||
using static Libplanet.Store.StoreExtension; | ||
|
||
namespace Libplanet.Tests.Store | ||
{ | ||
public class StoreExtensionTest | ||
{ | ||
public static IEnumerable<object[]> StoreFixtures | ||
{ | ||
get | ||
{ | ||
yield return new object[] { new FileStoreFixture() }; | ||
yield return new object[] { new LiteDBStoreFixture() }; | ||
} | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(StoreFixtures))] | ||
public void LookupStateReference(StoreFixture fx) | ||
{ | ||
Address address = fx.Address1; | ||
|
||
Transaction<DumbAction> tx4 = fx.MakeTransaction( | ||
new DumbAction[] { new DumbAction(address, "foo") } | ||
); | ||
Block<DumbAction> block4 = TestUtils.MineNext(fx.Block3, new[] { tx4 }); | ||
|
||
Transaction<DumbAction> tx5 = fx.MakeTransaction( | ||
new DumbAction[] { new DumbAction(address, "bar") } | ||
); | ||
Block<DumbAction> block5 = TestUtils.MineNext(block4, new[] { tx5 }); | ||
|
||
Block<DumbAction> block6 = TestUtils.MineNext(block5, new Transaction<DumbAction>[0]); | ||
|
||
Assert.Null(fx.Store.LookupStateReference(fx.StoreNamespace, address, fx.Block3)); | ||
Assert.Null(fx.Store.LookupStateReference(fx.StoreNamespace, address, block4)); | ||
Assert.Null(fx.Store.LookupStateReference(fx.StoreNamespace, address, block5)); | ||
Assert.Null(fx.Store.LookupStateReference(fx.StoreNamespace, address, block6)); | ||
|
||
fx.Store.StoreStateReference(fx.StoreNamespace, tx4.UpdatedAddresses, block4); | ||
Assert.Null(fx.Store.LookupStateReference(fx.StoreNamespace, address, fx.Block3)); | ||
Assert.Equal( | ||
block4.Hash, | ||
fx.Store.LookupStateReference(fx.StoreNamespace, address, block4) | ||
); | ||
Assert.Equal( | ||
block4.Hash, | ||
fx.Store.LookupStateReference(fx.StoreNamespace, address, block5) | ||
); | ||
Assert.Equal( | ||
block4.Hash, | ||
fx.Store.LookupStateReference(fx.StoreNamespace, address, block6) | ||
); | ||
|
||
fx.Store.StoreStateReference(fx.StoreNamespace, tx5.UpdatedAddresses, block5); | ||
Assert.Null(fx.Store.LookupStateReference(fx.StoreNamespace, address, fx.Block3)); | ||
Assert.Equal( | ||
block4.Hash, | ||
fx.Store.LookupStateReference(fx.StoreNamespace, address, block4) | ||
); | ||
Assert.Equal( | ||
block5.Hash, | ||
fx.Store.LookupStateReference(fx.StoreNamespace, address, block5) | ||
); | ||
Assert.Equal( | ||
block5.Hash, | ||
fx.Store.LookupStateReference(fx.StoreNamespace, address, block6) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.