Skip to content

Commit

Permalink
feature: fix instruction name and added test for domain transfer
Browse files Browse the repository at this point in the history
Signed-off-by: Timur Guskov <[email protected]>
  • Loading branch information
gv-timur committed Oct 24, 2023
1 parent bfdea5d commit fa3b95a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) {
instructions.value.add(Instructions.transferAsset(sourceId, value, destinationId))
}

fun transferDomain(sourceId: AccountId, value: IdBox.DomainId, destinationId: AccountId) = this.apply {
fun transferDomainOwnership(sourceId: AccountId, value: IdBox.DomainId, destinationId: AccountId) = this.apply {
instructions.value.add(Instructions.transferDomainOwnership(sourceId, value, destinationId))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import jp.co.soramitsu.iroha2.generated.AssetDefinitionId
import jp.co.soramitsu.iroha2.generated.AssetId
import jp.co.soramitsu.iroha2.generated.AssetValue
import jp.co.soramitsu.iroha2.generated.AssetValueType
import jp.co.soramitsu.iroha2.generated.IdBox
import jp.co.soramitsu.iroha2.generated.Metadata
import jp.co.soramitsu.iroha2.generated.Name
import jp.co.soramitsu.iroha2.generated.PermissionToken
Expand All @@ -35,6 +36,7 @@ import jp.co.soramitsu.iroha2.testengine.DEFAULT_ASSET_DEFINITION_ID
import jp.co.soramitsu.iroha2.testengine.DEFAULT_ASSET_ID
import jp.co.soramitsu.iroha2.testengine.DEFAULT_DOMAIN_ID
import jp.co.soramitsu.iroha2.testengine.DefaultGenesis
import jp.co.soramitsu.iroha2.testengine.GENESIS
import jp.co.soramitsu.iroha2.testengine.IROHA_CONFIG_DELIMITER
import jp.co.soramitsu.iroha2.testengine.IrohaTest
import jp.co.soramitsu.iroha2.testengine.NewAccountWithMetadata
Expand Down Expand Up @@ -1020,6 +1022,37 @@ class InstructionsTest : IrohaTest<Iroha2Client>() {
assertEquals(27, domains.size)
}

@Test
@WithIroha([DefaultGenesis::class])
@Feature("Domains")
@Story("Account transfers domain ownership")
@SdkTestId("transfer_domain_ownership")
fun `transfer domain ownership`(): Unit = runBlocking {
val genesisAccountId = AccountId(GENESIS.asName(), GENESIS.asDomainId())
var domain = QueryBuilder.findDomainById(DEFAULT_DOMAIN_ID)
.account(super.account)
.buildSigned(super.keyPair)
.let { query ->
client.sendQuery(query)
}
assertEquals(genesisAccountId, domain.ownedBy)

client.tx {
transferDomainOwnership(
genesisAccountId,
IdBox.DomainId(DEFAULT_DOMAIN_ID),
BOB_ACCOUNT_ID,
)
}
domain = QueryBuilder.findDomainById(DEFAULT_DOMAIN_ID)
.account(super.account)
.buildSigned(super.keyPair)
.let { query ->
client.sendQuery(query)
}
assertEquals(BOB_ACCOUNT_ID, domain.ownedBy)
}

private suspend fun registerAccount(id: AccountId, publicKey: PublicKey) {
client.sendTransaction {
account(super.account)
Expand Down

0 comments on commit fa3b95a

Please sign in to comment.