@@ -72,7 +72,6 @@ func TestPublish(t *testing.T) {
7272 GenesisHash : "" ,
7373 HasCampaign : false ,
7474 CampaignID : 0 ,
75- AccountBalance : sdk .NewCoins (),
7675 },
7776 ).
7877 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
@@ -91,6 +90,69 @@ func TestPublish(t *testing.T) {
9190 suite .AssertAllMocks (t )
9291 })
9392
93+ t .Run ("publish chain with custom account balance" , func (t * testing.T ) {
94+ var (
95+ account = testutil .NewTestAccount (t , testutil .TestAccountName )
96+ suite , network = newSuite (account )
97+ )
98+
99+ accountBalance , err := sdk .ParseCoinsNormalized ("1000foo,500bar" )
100+ require .NoError (t , err )
101+
102+ addr , err := account .Address (networktypes .SPN )
103+ require .NoError (t , err )
104+
105+ suite .ProfileQueryMock .
106+ On (
107+ "CoordinatorByAddress" ,
108+ context .Background (),
109+ & profiletypes.QueryGetCoordinatorByAddressRequest {
110+ Address : addr ,
111+ },
112+ ).
113+ Return (& profiletypes.QueryGetCoordinatorByAddressResponse {
114+ CoordinatorByAddress : profiletypes.CoordinatorByAddress {
115+ Address : addr ,
116+ CoordinatorID : 1 ,
117+ },
118+ }, nil ).
119+ Once ()
120+ suite .CosmosClientMock .
121+ On (
122+ "BroadcastTx" ,
123+ account ,
124+ & launchtypes.MsgCreateChain {
125+ Coordinator : addr ,
126+ GenesisChainID : testutil .ChainID ,
127+ SourceURL : testutil .ChainSourceURL ,
128+ SourceHash : testutil .ChainSourceHash ,
129+ GenesisURL : "" ,
130+ GenesisHash : "" ,
131+ HasCampaign : false ,
132+ CampaignID : 0 ,
133+ AccountBalance : accountBalance ,
134+ },
135+ ).
136+ Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
137+ LaunchID : testutil .LaunchID ,
138+ }), nil ).
139+ Once ()
140+ suite .ChainMock .On ("SourceHash" ).Return (testutil .ChainSourceHash ).Once ()
141+ suite .ChainMock .On ("SourceURL" ).Return (testutil .ChainSourceURL ).Once ()
142+ suite .ChainMock .On ("ChainID" ).Return (testutil .ChainID , nil ).Once ()
143+ suite .ChainMock .On ("CacheBinary" , testutil .LaunchID ).Return (nil ).Once ()
144+
145+ launchID , campaignID , publishError := network .Publish (
146+ context .Background (),
147+ suite .ChainMock ,
148+ WithAccountBalance (accountBalance ),
149+ )
150+ require .NoError (t , publishError )
151+ require .Equal (t , testutil .LaunchID , launchID )
152+ require .Equal (t , uint64 (0 ), campaignID )
153+ suite .AssertAllMocks (t )
154+ })
155+
94156 t .Run ("publish chain with pre created campaign" , func (t * testing.T ) {
95157 var (
96158 account = testutil .NewTestAccount (t , testutil .TestAccountName )
@@ -138,7 +200,6 @@ func TestPublish(t *testing.T) {
138200 GenesisHash : "" ,
139201 HasCampaign : true ,
140202 CampaignID : testutil .CampaignID ,
141- AccountBalance : sdk .NewCoins (),
142203 },
143204 ).
144205 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
@@ -226,7 +287,6 @@ func TestPublish(t *testing.T) {
226287 GenesisHash : "" ,
227288 HasCampaign : true ,
228289 CampaignID : testutil .CampaignID ,
229- AccountBalance : sdk .NewCoins (),
230290 },
231291 ).
232292 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
@@ -291,7 +351,6 @@ func TestPublish(t *testing.T) {
291351 GenesisHash : customGenesisHash ,
292352 HasCampaign : false ,
293353 CampaignID : 0 ,
294- AccountBalance : sdk .NewCoins (),
295354 },
296355 ).
297356 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
@@ -346,7 +405,6 @@ func TestPublish(t *testing.T) {
346405 GenesisHash : "" ,
347406 HasCampaign : false ,
348407 CampaignID : 0 ,
349- AccountBalance : sdk .NewCoins (),
350408 },
351409 ).
352410 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
@@ -543,7 +601,6 @@ func TestPublish(t *testing.T) {
543601 GenesisHash : "" ,
544602 HasCampaign : false ,
545603 CampaignID : 0 ,
546- AccountBalance : sdk .NewCoins (),
547604 },
548605 ).
549606 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
@@ -690,7 +747,6 @@ func TestPublish(t *testing.T) {
690747 GenesisHash : "" ,
691748 HasCampaign : false ,
692749 CampaignID : 0 ,
693- AccountBalance : sdk .NewCoins (),
694750 },
695751 ).
696752 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
@@ -745,7 +801,6 @@ func TestPublish(t *testing.T) {
745801 GenesisHash : "" ,
746802 HasCampaign : false ,
747803 CampaignID : 0 ,
748- AccountBalance : sdk .NewCoins (),
749804 },
750805 ).
751806 Return (testutil .NewResponse (& launchtypes.MsgCreateChainResponse {
0 commit comments