Skip to content

Commit 570818f

Browse files
authored
Merge pull request #2708 from planetarium/release/1.15.0
Release/1.15.0
2 parents a5dd5bd + fef54f5 commit 570818f

File tree

97 files changed

+7262
-2243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+7262
-2243
lines changed

.Lib9c.Benchmarks/Lib9c.Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<ProjectReference Include="..\.Libplanet\Libplanet.RocksDBStore\Libplanet.RocksDBStore.csproj" />
16-
<ProjectReference Include="..\.Libplanet\Libplanet\Libplanet.csproj" />
15+
<ProjectReference Include="..\.Libplanet\src\Libplanet.RocksDBStore\Libplanet.RocksDBStore.csproj" />
16+
<ProjectReference Include="..\.Libplanet\src\Libplanet\Libplanet.csproj" />
1717
<ProjectReference Include="..\Lib9c\Lib9c.csproj" />
1818
<ProjectReference Include="..\Lib9c.Policy\Lib9c.Policy.csproj" />
1919
<ProjectReference Include="..\Libplanet.Crypto.Secp256k1\Libplanet.Crypto.Secp256k1.csproj" />

.Lib9c.Tests/Action/ActionContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Lib9c.Tests.Action
88
using Libplanet.Common;
99
using Libplanet.Crypto;
1010
using Libplanet.Types.Blocks;
11+
using Libplanet.Types.Evidence;
1112
using Libplanet.Types.Tx;
1213

1314
public class ActionContext : IActionContext
@@ -18,6 +19,8 @@ public class ActionContext : IActionContext
1819

1920
private IReadOnlyList<ITransaction> _txs = null;
2021

22+
private IReadOnlyList<EvidenceBase> _evs = null;
23+
2124
public BlockHash? GenesisHash { get; set; }
2225

2326
public Address Signer { get; set; }
@@ -46,6 +49,12 @@ public IReadOnlyList<ITransaction> Txs
4649
set => _txs = value;
4750
}
4851

52+
public IReadOnlyList<EvidenceBase> Evidence
53+
{
54+
get => _evs ?? ImmutableList<EvidenceBase>.Empty;
55+
set => _evs = value;
56+
}
57+
4958
public void UseGas(long gas)
5059
{
5160
_gasUsed += gas;

.Lib9c.Tests/Action/AdventureBoss/ClaimAdventureBossRewardTest.cs

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ public static IEnumerable<object[]> GetWantedTestData()
125125
ItemReward = new Dictionary<int, int>
126126
{
127127
{ 600201, 168 },
128-
{ 600202, 0 },
128+
{ 600202, 18 },
129129
{ 600203, 0 },
130130
},
131131
FavReward = new Dictionary<int, int>
132132
{
133-
{ 20001, 14 },
133+
{ 20001, 0 },
134134
{ 30001, 0 },
135135
},
136136
},
@@ -147,12 +147,12 @@ public static IEnumerable<object[]> GetWantedTestData()
147147
{
148148
600201, 168
149149
}, // (200*1.2) * 0.7 / 0.5 * (120/240)
150-
{ 600202, 0 },
150+
{ 600202, 18 }, // (200*1.2) * 0.3 / 2 * (120/240)
151151
{ 600203, 0 },
152152
},
153153
FavReward = new Dictionary<int, int>
154154
{
155-
{ 20001, 14 }, // (200*1.2) * 0.3 / 2.5 * (120/240)
155+
{ 20001, 0 },
156156
{ 30001, 0 },
157157
},
158158
},
@@ -169,12 +169,12 @@ public static IEnumerable<object[]> GetWantedTestData()
169169
{
170170
600201, 140
171171
}, // (300*1.2) * 0.7 / 0.5 * (100/360)
172-
{ 600202, 0 },
172+
{ 600202, 15 }, // (300*1.2) * 0.3 / 2 * (100/360)
173173
{ 600203, 0 },
174174
},
175175
FavReward = new Dictionary<int, int>
176176
{
177-
{ 20001, 11 }, // (300*1.2) * 0.3 / 2.5 * (100/360)
177+
{ 20001, 0 },
178178
{ 30001, 0 },
179179
},
180180
},
@@ -190,8 +190,8 @@ public static IEnumerable<object[]> GetExploreTestData()
190190
NcgReward = (5 + 15) * NCG, // 5NCG for raffle, 15NCG for 15% distribution
191191
ItemReward = new Dictionary<int, int>
192192
{
193-
{ 600201, 0 },
194-
{ 600202, 66 }, // 100AP / 1.5 ratio * 100% contribution
193+
{ 600201, 80 }, // 100AP * 0.4 Exchange / 0.5 ratio * 100% contribution
194+
{ 600202, 0 },
195195
{ 600203, 0 },
196196
},
197197
FavReward = new Dictionary<int, int>
@@ -215,8 +215,10 @@ public static IEnumerable<object[]> GetExploreTestData()
215215
),
216216
ItemReward = new Dictionary<int, int>
217217
{
218-
{ 600201, 0 },
219-
{ 600202, 66 }, // total 200 AP / 1.5 ratio * 50% contribution
218+
{
219+
600201, 79
220+
}, // total 200 AP * 0.4 Exchange / 0.5 ratio * 50% contribution
221+
{ 600202, 0 },
220222
{ 600203, 0 },
221223
},
222224
FavReward = new Dictionary<int, int>
@@ -237,8 +239,10 @@ public static IEnumerable<object[]> GetExploreTestData()
237239
NcgReward = 15 * NCG,
238240
ItemReward = new Dictionary<int, int>
239241
{
240-
{ 600201, 0 },
241-
{ 600202, 66 }, // Total 200 AP / 1.5 Ratio * 50% Contribution
242+
{
243+
600201, 79
244+
}, // Total 200 AP * 0.4 Exchange / 1.5 Ratio * 50% Contribution
245+
{ 600202, 0 },
242246
{ 600203, 0 },
243247
},
244248
FavReward = new Dictionary<int, int>
@@ -258,8 +262,8 @@ public static IEnumerable<object[]> GetExploreTestData()
258262
NcgReward = 5 * NCG,
259263
ItemReward = new Dictionary<int, int>
260264
{
261-
{ 600201, 0 },
262-
{ 600202, 66 },
265+
{ 600201, 80 },
266+
{ 600202, 0 },
263267
{ 600203, 0 },
264268
},
265269
FavReward = new Dictionary<int, int>
@@ -282,12 +286,12 @@ public static IEnumerable<object[]> GetPrevRewardTestData()
282286
ItemReward = new Dictionary<int, int>
283287
{
284288
{ 600201, 168 },
285-
{ 600202, 0 },
289+
{ 600202, 18 },
286290
{ 600203, 0 },
287291
},
288292
FavReward = new Dictionary<int, int>
289293
{
290-
{ 20001, 14 },
294+
{ 20001, 0 },
291295
{ 30001, 0 },
292296
},
293297
},
@@ -300,8 +304,8 @@ public static IEnumerable<object[]> GetPrevRewardTestData()
300304
NcgReward = 20 * NCG, // 5NCG for explore raffle, 15NCG for 15% distribution
301305
ItemReward = new Dictionary<int, int>
302306
{
303-
{ 600201, 0 },
304-
{ 600202, 66 },
307+
{ 600201, 80 },
308+
{ 600202, 0 },
305309
{ 600203, 0 },
306310
},
307311
FavReward = new Dictionary<int, int>
@@ -320,13 +324,13 @@ public static IEnumerable<object[]> GetPrevRewardTestData()
320324
NcgReward = 20 * NCG,
321325
ItemReward = new Dictionary<int, int>
322326
{
323-
{ 600201, 168 },
324-
{ 600202, 66 },
327+
{ 600201, 248 },
328+
{ 600202, 18 },
325329
{ 600203, 0 },
326330
},
327331
FavReward = new Dictionary<int, int>
328332
{
329-
{ 20001, 14 },
333+
{ 20001, 0 },
330334
{ 30001, 0 },
331335
},
332336
},
@@ -438,13 +442,13 @@ public void WantedMultipleSeason()
438442
NcgReward = 0 * NCG, // No Raffle Reward
439443
FavReward = new Dictionary<int, int>
440444
{
441-
{ 20001, 28 },
445+
{ 20001, 0 },
442446
{ 30001, 0 },
443447
},
444448
ItemReward = new Dictionary<int, int>
445449
{
446450
{ 600201, 336 },
447-
{ 600202, 0 },
451+
{ 600202, 36 },
448452
{ 600203, 0 },
449453
},
450454
};
@@ -708,8 +712,10 @@ public void ExploreMultipleSeason()
708712
},
709713
ItemReward = new Dictionary<int, int>
710714
{
711-
{ 600201, 0 },
712-
{ 600202, 132 }, // (100 AP / 1.5 Ratio * 100% contribution) for season 1 and 3
715+
{
716+
600201, 160
717+
}, // (100 AP * 0.4 Exchange / 0.5 Ratio * 100% contribution) for season 1 and 3
718+
{ 600202, 0 },
713719
{ 600203, 0 },
714720
},
715721
};
@@ -831,13 +837,13 @@ public void AllReward()
831837
NcgReward = 20 * NCG,
832838
FavReward = new Dictionary<int, int>
833839
{
834-
{ 20001, 14 },
840+
{ 20001, 0 },
835841
{ 30001, 0 },
836842
},
837843
ItemReward = new Dictionary<int, int>
838844
{
839-
{ 600201, 168 },
840-
{ 600202, 66 },
845+
{ 600201, 248 },
846+
{ 600202, 18 },
841847
{ 600203, 0 },
842848
},
843849
};

.Lib9c.Tests/Action/AdventureBoss/ExploreAdventureBossTest.cs

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,58 +98,79 @@ public static IEnumerable<object[]> GetExecuteMemberData()
9898
// No AP potion at all
9999
yield return new object[]
100100
{
101-
0, 5, 0, 0, 0, null, new (int, int)[] { },
101+
0, 5, 0, 0, 0, null, new (int, int)[] { }, new (int, int)[] { },
102102
};
103103
// Start from bottom, goes to 5
104104
yield return new object[]
105105
{
106-
0, 5, 5, 10, 5, null,
106+
0, 5, 5, 20, 10, null, // 2 potions per floor
107107
new[]
108108
{
109-
(600301, 76), // 50 first Reward + 26 floor reward
110-
(600302, 50), // 50 first reward
111-
(600303, 0),
109+
(600301, 10), // 10 floor reward
110+
(600302, 30), // 10+5+5+5+5 first reward
111+
(600303, 4), // 2+2 first reward
112112
(600304, 0),
113113
},
114+
new[]
115+
{
116+
(10033, 5), // 5 first reward
117+
(10034, 8), // 5 first reward + 3 floor reward
118+
},
114119
};
115120
// Start from bottom, goes to 3 because of potion
116121
yield return new object[]
117122
{
118-
0, 5, 3, 3, 0, null, new[]
123+
0, 5, 3, 6, 0, null, new[]
119124
{
120-
(600301, 47), // 30 first reward + 17 floor reward
121-
(600302, 30), // 30 first reward
122-
(600303, 0),
125+
(600301, 7), // 7 floor reward
126+
(600302, 20), // 10+5+5 first reward
127+
(600303, 4), // 2+2 first reward
123128
(600304, 0),
124129
},
130+
new[]
131+
{
132+
(10033, 0),
133+
(10034, 0),
134+
},
125135
};
126136
// Start from 3, goes to 5 because of locked floor
127137
yield return new object[]
128138
{
129-
2, 5, 5, 5, 2, null, new[]
139+
2, 5, 5, 10, 4, null, new[]
130140
{
131-
(600301, 40), // 30 first reward + 10 floor reward
132-
(600302, 39), // 30 first reward + 9 floor reward
133-
(600303, 0),
141+
(600301, 4), // 4 floor reward
142+
(600302, 15), // 5+5+5 first reward
143+
(600303, 2), // 2 first reward
134144
(600304, 0),
135145
},
146+
new[]
147+
{
148+
(10033, 8), // 5 first reward + 3 floor reward
149+
(10034, 5), // 5 first reward
150+
},
136151
};
137-
// Start from 6, goes to 10
152+
// Start from 6, goes to 9
138153
yield return new object[]
139154
{
140-
5, 10, 10, 10, 5, null,
155+
5, 10, 9, 20, 10, null,
141156
new[]
142157
{
143-
(600301, 72), // 50 first reward + 22 floor reward
144-
(600302, 50), // 50 first reward
145-
(600303, 0),
158+
(600203, 5), // 5 first reward
159+
(600301, 0),
160+
(600302, 5), // 5 floor reward
161+
(600303, 15), // 5+5+5 first reward
146162
(600304, 0),
147163
},
164+
new[]
165+
{
166+
(10033, 8), // 5 first reward + 3 floor reward
167+
(10034, 3), // 3 floor reward
168+
},
148169
};
149170
// Start from 20, cannot enter
150171
yield return new object[]
151172
{
152-
20, 20, 20, 10, 10, typeof(InvalidOperationException), null,
173+
20, 20, 20, 10, 10, typeof(InvalidOperationException), null, null,
153174
};
154175
}
155176

@@ -162,7 +183,8 @@ public void Execute(
162183
int initialPotion,
163184
int expectedPotion,
164185
Type exc,
165-
(int, int)[] expectedRewards
186+
(int, int)[] expectedItemRewards,
187+
(int, int)[] expectedFavRewards
166188
)
167189
{
168190
// Settings
@@ -179,6 +201,7 @@ public void Execute(
179201
var sheets = state.GetSheets(sheetTypes: new[]
180202
{
181203
typeof(MaterialItemSheet),
204+
typeof(RuneSheet),
182205
});
183206
var materialSheet = sheets.GetSheet<MaterialItemSheet>();
184207
var materialRow =
@@ -275,7 +298,7 @@ public void Execute(
275298
Assert.Equal(expectedFloor, explorer.Floor);
276299

277300
var inventory = state.GetInventoryV2(TesterAvatarAddress);
278-
foreach (var (id, amount) in expectedRewards)
301+
foreach (var (id, amount) in expectedItemRewards)
279302
{
280303
if (amount == 0)
281304
{
@@ -287,6 +310,14 @@ public void Execute(
287310
}
288311
}
289312

313+
var runeSheet = sheets.GetSheet<RuneSheet>();
314+
foreach (var (id, amount) in expectedFavRewards)
315+
{
316+
var ticker = runeSheet.Values.First(rune => rune.Id == id).Ticker;
317+
var currency = Currencies.GetRune(ticker);
318+
Assert.Equal(amount, state.GetBalance(TesterAvatarAddress, currency).RawValue);
319+
}
320+
290321
itemSlotState =
291322
state.TryGetLegacyState(itemSlotStateAddress, out rawItemSlotState)
292323
? new ItemSlotState(rawItemSlotState)

.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ public static IEnumerable<object[]> GetExecuteMemberData()
8787
};
8888
yield return new object[]
8989
{
90-
1, 100, 98, null, new[] { (600301, 8), (600302, 0), (600303, 0), (600304, 0), },
90+
1, 100, 99, null, new[] { (600301, 3), (600302, 0), (600303, 0), (600304, 0), },
9191
};
9292
yield return new object[]
9393
{
9494
1, 0, 0, typeof(NotEnoughMaterialException), null,
9595
};
9696
yield return new object[]
9797
{
98-
10, 10, 10, typeof(NotEnoughMaterialException), null,
98+
10, 1, 1, typeof(NotEnoughMaterialException), null,
9999
};
100100
yield return new object[]
101101
{
102-
20, 40, 0, null, new[] { (600301, 67), (600302, 67), (600303, 0), (600304, 0), },
102+
20, 20, 0, null, new[] { (600301, 9), (600302, 10), (600303, 8), (600304, 8), },
103103
};
104104
}
105105

0 commit comments

Comments
 (0)