@@ -6,11 +6,14 @@ module ob_launchpad::test_fees {
6
6
use sui::test_scenario::{Self , ctx};
7
7
8
8
use ob_launchpad::flat_fee;
9
+ use ob_launchpad::fee_cut;
9
10
use ob_launchpad::listing;
10
11
use ob_launchpad::test_listing;
11
12
12
13
const MARKETPLACE : address = @0xA123 ;
13
14
const CREATOR : address = @0xA1C05 ;
15
+ const CUT_ADDR_1 : address = @0x1 ;
16
+ const CUT_ADDR_2 : address = @0x2 ;
14
17
15
18
#[test]
16
19
public fun marketplace_default_fee () {
@@ -110,4 +113,62 @@ module ob_launchpad::test_fees {
110
113
test_scenario::return_shared (listing);
111
114
test_scenario::end (scenario);
112
115
}
116
+
117
+ #[test]
118
+ public fun test_fee_cut () {
119
+ let scenario = test_scenario::begin (MARKETPLACE );
120
+
121
+ // Creates `Marketplace` with default fee
122
+ let (marketplace, listing) = test_listing::init_listing_and_marketplace (
123
+ CREATOR , MARKETPLACE , 2000 , &mut scenario,
124
+ );
125
+
126
+ fee_cut::add_fee_cut (
127
+ &mut marketplace,
128
+ &mut listing,
129
+ CUT_ADDR_1 ,
130
+ 70 ,
131
+ ctx (&mut scenario)
132
+ );
133
+
134
+ fee_cut::add_fee_cut (
135
+ &mut marketplace,
136
+ &mut listing,
137
+ CUT_ADDR_2 ,
138
+ 30 ,
139
+ ctx (&mut scenario)
140
+ );
141
+
142
+ listing::pay (&mut listing, balance::create_for_testing <SUI >(10_000 ), 1 );
143
+
144
+ flat_fee::collect_proceeds_and_fees <SUI >(
145
+ &marketplace, &mut listing, ctx (&mut scenario),
146
+ );
147
+
148
+ test_scenario::next_tx (&mut scenario, MARKETPLACE );
149
+
150
+ let marketplace_proceeds =
151
+ test_scenario::take_from_address <Coin <SUI >>(&scenario, MARKETPLACE );
152
+ assert !(coin::value (&marketplace_proceeds) == 1_980 , 0 );
153
+
154
+ test_scenario::return_to_address (MARKETPLACE , marketplace_proceeds);
155
+
156
+ let creator_proceeds =
157
+ test_scenario::take_from_address <Coin <SUI >>(&scenario, CREATOR );
158
+ assert !(coin::value (&creator_proceeds) == 7_920 , 0 );
159
+
160
+ let addr1_proceeds = test_scenario::take_from_address <Coin <SUI >>(&scenario, CUT_ADDR_1 );
161
+ assert !(coin::value (&addr1_proceeds) == 70 , 0 );
162
+
163
+ let addr2_proceeds = test_scenario::take_from_address <Coin <SUI >>(&scenario, CUT_ADDR_2 );
164
+ assert !(coin::value (&addr2_proceeds) == 30 , 0 );
165
+
166
+ test_scenario::return_to_address (CREATOR , creator_proceeds);
167
+ test_scenario::return_to_address (CUT_ADDR_1 , addr1_proceeds);
168
+ test_scenario::return_to_address (CUT_ADDR_2 , addr2_proceeds);
169
+
170
+ test_scenario::return_shared (marketplace);
171
+ test_scenario::return_shared (listing);
172
+ test_scenario::end (scenario);
173
+ }
113
174
}
0 commit comments