La arquitectura de las aplicaciones descentralizadas
Construye aplicaciones descentralizadas
Fundamentos de Ethereum
Arquitectura de una Dapp
Creando una billetera virtual
Setup local de un Dapp con Hardhat
Setear tu ambiente de trabajo local con Hardhat
Escribiendo y compilando tu primer Smart-contract
Creando pruebas unitarias
Desplegar un Smart-contract localmente con Hardhat
Desplegando el Smart-contract localmente con Hardhat
Desplegar un Smart-contract en Rinkeby
Actualización sobre testnet en Ethereum
Desplegando nuestro smart contract en una blockchain de test (Rinkeby)
Inicializando nuestro frontend en React/NextJS
Verificar conexión de Ethereum
Conectando Metamask a nuestro frontend
Integrar un Smart-contract con el Front-end
Almacenando información en blockchain desde el frontend
Leyendo nuestro smart contract desde el frontend
Eventos
Conclusiones
Consejos para optimizar el consumo de gas
Panorama de Ethereum
Conclusiones sobre la arquitectura de las dapps
No tienes acceso a esta clase
¡Continúa aprendiendo! Únete y comienza a potenciar tu carrera
Aportes 3
Preguntas 0
const { ethers } = require("hardhat");
const { expect } = require("chai");
describe("PlatziFood", () => {
const setup = async () => {
const accounts = await ethers.getSigners();
const PlatziFood = await ethers.getContractFactory("PlatziFood");
const deployed = await PlatziFood.deploy();
return {
accounts,
deployed,
};
};
describe("PlatziFood Contract", () => {
it("getAllPlatziFoods return an empty PlatziFoodItem[]", async () => {
const { deployed } = await setup();
expect(await deployed.getAllPlatziFoods()).to.eql([]);
});
it("addPlatziPunk added correctly and array in platziFoods", async () => {
const { deployed, accounts } = await setup();
const signer = accounts[0].address;
const foodUrl = "test";
const foodName = "Pollito";
const originCountry = "CO";
await deployed.addPlatziFood(foodUrl, foodName, originCountry);
expect(await deployed.getAllPlatziFoods()).to.eql([
[signer, foodUrl, foodName, originCountry],
]);
});
describe("getPlatziFoodByOwner", async () => {
it("should return all platzi food by owner", async () => {
const { deployed } = await setup();
const foodUrl = "test";
const foodName = "Pollito";
const originCountry = "CO";
await deployed.addPlatziFood(foodUrl, foodName, originCountry);
// ==============================
const foodUrl2 = "test";
const foodName2 = "Carnita";
const originCountry2 = "VE";
await deployed.addPlatziFood(foodUrl2, foodName2, originCountry2);
// ==============================
const getAllFoodsByMainSigner = await deployed.getPlatziFoodsByOwner();
expect(getAllFoodsByMainSigner.length).to.equal(2);
});
it("should return all platzi food by another address", async () => {
const { accounts, deployed } = await setup();
const signer = accounts[1];
const foodUrl = "test";
const foodName = "Carnita";
const originCountry = "VE";
await deployed
.connect(signer)
.addPlatziFood(foodUrl, foodName, originCountry);
expect(
await deployed.connect(signer).getPlatziFoodsByOwner()
).to.have.lengthOf(1);
});
});
});
});
Las pruebas son muy importantes ya que ayudan a detectar errores y así evitar re trabajos que consumen tiempo y a diferencia de web2 también conllevan costos económicos altos.
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?