Apply Composer changes: comprehensive API updates, migrations, middleware, and infrastructure improvements
- Add comprehensive database migrations (001-024) for schema evolution - Enhance API schema with expanded type definitions and resolvers - Add new middleware: audit logging, rate limiting, MFA enforcement, security, tenant auth - Implement new services: AI optimization, billing, blockchain, compliance, marketplace - Add adapter layer for cloud integrations (Cloudflare, Kubernetes, Proxmox, storage) - Update Crossplane provider with enhanced VM management capabilities - Add comprehensive test suite for API endpoints and services - Update frontend components with improved GraphQL subscriptions and real-time updates - Enhance security configurations and headers (CSP, CORS, etc.) - Update documentation and configuration files - Add new CI/CD workflows and validation scripts - Implement design system improvements and UI enhancements
This commit is contained in:
74
blockchain/tests/ResourceProvisioning.test.ts
Normal file
74
blockchain/tests/ResourceProvisioning.test.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { expect } from 'chai'
|
||||
import { ethers } from 'hardhat'
|
||||
import { ResourceProvisioning } from '../typechain-types'
|
||||
|
||||
describe('ResourceProvisioning', function () {
|
||||
let contract: ResourceProvisioning
|
||||
let owner: any
|
||||
let addr1: any
|
||||
|
||||
beforeEach(async function () {
|
||||
;[owner, addr1] = await ethers.getSigners()
|
||||
|
||||
const ResourceProvisioningFactory = await ethers.getContractFactory('ResourceProvisioning')
|
||||
contract = await ResourceProvisioningFactory.deploy()
|
||||
await contract.waitForDeployment()
|
||||
})
|
||||
|
||||
describe('Resource Provisioning', function () {
|
||||
it('Should provision a new resource', async function () {
|
||||
const tx = await contract.provisionResource(
|
||||
'resource-001',
|
||||
'us-east-1',
|
||||
'datacenter-1',
|
||||
0, // VM
|
||||
'{"cpu": 4, "memory": 8192}'
|
||||
)
|
||||
|
||||
await expect(tx)
|
||||
.to.emit(contract, 'ResourceProvisioned')
|
||||
.withArgs('resource-001', 'us-east-1', 0, owner.address, await ethers.provider.getBlockNumber())
|
||||
|
||||
const resource = await contract.getResource('resource-001')
|
||||
expect(resource.resourceId).to.equal('resource-001')
|
||||
expect(resource.active).to.equal(true)
|
||||
})
|
||||
|
||||
it('Should not allow provisioning duplicate resource', async function () {
|
||||
await contract.provisionResource(
|
||||
'resource-001',
|
||||
'us-east-1',
|
||||
'datacenter-1',
|
||||
0,
|
||||
'{}'
|
||||
)
|
||||
|
||||
await expect(
|
||||
contract.provisionResource(
|
||||
'resource-001',
|
||||
'us-east-1',
|
||||
'datacenter-1',
|
||||
0,
|
||||
'{}'
|
||||
)
|
||||
).to.be.revertedWith('Resource already exists')
|
||||
})
|
||||
|
||||
it('Should deprovision a resource', async function () {
|
||||
await contract.provisionResource(
|
||||
'resource-001',
|
||||
'us-east-1',
|
||||
'datacenter-1',
|
||||
0,
|
||||
'{}'
|
||||
)
|
||||
|
||||
const tx = await contract.deprovisionResource('resource-001')
|
||||
await expect(tx).to.emit(contract, 'ResourceDeprovisioned')
|
||||
|
||||
const resource = await contract.getResource('resource-001')
|
||||
expect(resource.active).to.equal(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user